atoti_plus.user_service_client.basic.security module#

class atoti_plus.BasicSecurity#

Manage basic authentication on the session.

Note

This requires a BasicAuthenticationConfig to be passed to Session()’s authentication parameter.

create_user(username, *, password=None, **kwargs)#

Add a user able to authenticate against the session using Basic Authentication.

Users without the role ROLE_USER will not have access to the application.

Parameters
  • username (str) – The name of the user.

  • password (Optional[str]) – The password of the user, can be changed at any time.

Return type

User

Example

>>> from atoti_plus import UserServiceClient
>>> session = tt.Session(authentication=tt.BasicAuthenticationConfig())
>>> client = UserServiceClient.from_session(session)
>>> list(client.basic.users)
[]
>>> elon = client.basic.create_user("elon", password="X Æ A-12")
>>> list(client.basic.users)
['elon']
>>> # The special `ROLE_USER` role is automatically added:
>>> list(client.individual_roles[elon.username])
['ROLE_USER']
>>> # Change the password
>>> elon.password = "AE A-XII"
>>> # Revoke access
>>> del client.basic.users[elon.username]
>>> list(client.basic.users)
[]
property users: BasicUsers#
class atoti_plus.BasicUsers#

Manage basic authentication users.