Storage
lib.Storage
Storage
Storage(self, rc=None, use_in_memory_on_failure=True)
Represents a Safe for Tokens.
getUsers
Storage.getUsers()
Returns a list of all registered users.
getUser
Storage.getUser(user_id: str)
Returns the user with user_id.
Raise a UserNotExistsError
, if user not found.
getTokens
Storage.getTokens(user: typing.Union[str, RDS.User.User] = None)
Returns a list of all managed tokens.
If user_id (String or User) was given, then the tokens are filtered to this user.
Raise a UserNotExistsError, if the given user not exists.
getToken
Storage.getToken(user_id: typing.Union[str, RDS.User.User],
token_id: typing.Union[str, int])
Returns only the token with token_id (str or int) from user_id (Username as string or User).
token_id should be the servicename or the id for token in list.
Raise ValueError
if token_id not found and UserNotExistsError
if user_id was not found.
getServices
Storage.getServices()
Returns a list of all registered services.
getService
Storage.getService(service: typing.Union[str, RDS.Service.BaseService])
Returns the service object with the given servicename. If not found, returns None
This function can be used to check, if an object is already a member of the list of services.
Set parameter index
to True to get the index as the second return value in tuple.
addService
Storage.addService(service: BaseService, Force=False)
Add the given service to the list of services.
Returns True if success.
Otherwise raises a ServiceExistsAlreadyError
if there is already a service with the same name.
To force an update, you have to set the parameter Force
to True.
Raise an error, if parameter not a service object.
removeService
Storage.removeService(
service: typing.Union[str, RDS.Service.BaseService])
Removes the service with servicename.
Returns True if a service was found and removed. Otherwise false.
addUser
Storage.addUser(user: User)
Add user to the storage.
If a User with the same username already exists, it raises UserExistsAlreadyError.
removeUser
Storage.removeUser(user: User)
Remove given user from storage.
If user not in storage, it raises an UserNotExistsError.
internal_removeUser
Storage.internal_removeUser(user: User)
Remove a user to tokens.
This is an internal function. Please look at the external one.
removeToken
Storage.removeToken(user: User, token: Token)
Remove a token from user.
internal_removeToken
Storage.internal_removeToken(user: User, token: Token)
Remove a token from user.
This is an internal function. Please look at the external one.
If the first token will be deleted, it is the master token / login token, which was used to enable and RDS use this token for frontend actions. So we can assume, that the user wants to revoke all access through RDS. To accomplish this, we remove all data for this user in token storage.
internal_addUser
Storage.internal_addUser(user: User)
Add a user to storage as superuser.
This is an internal function. Please take a look to the external one.
addTokenToUser
Storage.addTokenToUser(token: Token,
user: User = None,
Force: bool = False)
Add a token to an existing user. If user not exists already in the tokens, it raises an UserNotExistsError.
If token was added to user specific storage, then it returns True
.
If a token is there for the same token provider, then a UserHasTokenAlreadyError.
Use Force
Parameter (boolean) to create User, if not already exists and overwrite any existing Token, too.
If user parameter not provided, it takes the user from token as superuser.
refresh_service
Storage.refresh_service(service: BaseService)
Refresh all tokens, which corresponds to given service.
Returns True, if one or more Tokens were found in the storage to refresh.
refresh_services
Storage.refresh_services(services: list = None)
Refresh all tokens, which corresponds to given list of services.
If no services were given, it will be used the stored one.
Returns True, if one or more Tokens were found in the storage to refresh.
internal_refresh_services
Storage.internal_refresh_services(services: list)
Only for internal use. Do not use it in another class.
Refresh all tokens, which corresponds to given list of services.
Returns True, if one or more Tokens were found in the storage to refresh.
internal_find_service
Storage.internal_find_service(servicename: str,
services: list,
return_object: bool = False)
Tries to find the given servicename in the list of services.
Returns the index of the first found service with equal servicename.
Otherwise raise an ValueError.
deprovizionize
Storage.deprovizionize()
Deletes all user informations, if last access timestamp is 180 days in past. For cleanup, it waits additional 30 days before it deletes the timestamp too.