Auth Module¶
The auth module contains the classes and function related to the authentication of the user.
Token Class¶
- The UserToken class has the following attributes:
user: {user_id, email: {verified: bool, value: str }
hash: str
expiry: str
name: str
tokenId: str
To get the token by using the root_secret_key you can use the UserToken.from_root_secret_key() function:
- UserToken.from_root_secret_key(root_secret_key, client)¶
Return the token object from the root_secret_key.
- Parameters:
root_secret_key (str) – root_secret_key of the user.
client (anonymization.client.BaseClient) – token of the user.
- Returns:
UserToken object
- Return type:
UserToken
To get the token by using the search parameters you can use the UserToken.from_search_params() function:
- UserToken.from_search_params(params, client)¶
Return the list token object from the search parameters.
- Parameters:
params (Dict[str, Any]) – search parameters of the user.
client (anonymization.client.BaseClient) – token of the user.
- Returns:
UserToken
- Return type:
List[UserToken]
User Class¶
The user class is the main class of the auth module. It contains the information of the user and the methods to authenticate the user.
- The User class has the following attributes:
name: str
email: {verified: bool, value: str }
role: str
user_id: str
root_secret_key:Optional[str]
To login the user you can use the User.from_login() function:
- User.from_login(email, password, client)¶
Return a user object from the login credentials.
- Parameters:
email (str) – email id of the user.
password (str) – password of the user.
client (anonymization.client.BaseClient) – token of the user.
- Returns:
User object
- Return type:
User
To get the user by its id you can use the User.from_user_id() function:
- User.from_user_id(user_id, client)¶
Return the user object from the user id.
- Parameters:
user_id (str) – id of the user.
client (anonymization.client.BaseClient) – token of the user.
- Returns:
User object
- Return type:
User