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, roles=())#

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.

  • roles (Iterable[str]) – Roles 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(elon.roles)
['ROLE_USER']
>>> # Change the password
>>> elon.password = "AE A-XII"
>>> # Revoke access
>>> del client.basic.users["elon"]
>>> list(client.basic.users)
[]
property users: BasicUsers#
class atoti_plus.BasicUsers#

Manage basic authentication users.