|
Mercury2 Hardware Manager
1.0dev
The hardware manager component of the Mercury2 ground station suite.
|
Stores and provides access to user permission settings. More...
Public Member Functions | |
| def | __init__ |
| Sets up the permission manager. More... | |
| def | get_user_permissions |
| Returns the permissions structure for the indicated user. More... | |
| def | purge_user_permissions |
| Removes all old permission settings. More... | |
Public Attributes | |
| permissions | |
| use_remote_permissions | |
| permissions_location | |
| config | |
| update_frequency | |
Private Member Functions | |
| def | _update_user_permissions |
| Updates the permissions for the indicated user. More... | |
| def | _download_remote_permissions |
| Loads the user's permissions from a remote location. More... | |
| def | _load_local_permissions |
| Load the user's permissions from a local file. More... | |
| def | _background_update_error |
| This callback responds to errors when updating the permissions in the background. More... | |
| def | _save_permissions |
| Saves the user command execution permission settings in the PermissionManager. More... | |
| def | _validate_permissions |
| Validates the provided permission settings. More... | |
Stores and provides access to user permission settings.
This class stores user command permission settings for use by the command parser and related classes. All permission settings are stored with an associated timestamp. This is used to invalidate permissions after a set amount of time, forcing a redownload.
| def hwm.network.security.permissions.PermissionManager.__init__ | ( | self, | |
| permissions_endpoint, | |||
| update_frequency | |||
| ) |
Sets up the permission manager.
| permissions_endpoint | The location that can be queried to find user command permissions. This can either be the mercury2 user interface API or a file. If this points to the mercury2 API, it must start with http or https. |
| update_frequency | How often the user's permissions should be updated (i.e. if a user's permissions are requested and the cached version is older than this value, update them). Specified in seconds. |
|
private |
This callback responds to errors when updating the permissions in the background.
| update_error | A Failure object containing the error. |
|
private |
Loads the user's permissions from a remote location.
This method loads the specified user's command execution permissions from a remote location (e.g. the mercury2 user interface) and returns them.
| PermissionsError | if an error occurs while downloading or parsing the schedule. |
| May | throw PermissionsInvalidSchema if the permission settings do not conform to the defined schema. |
| user_id | The ID of the user we want to download permissions for. |
|
private |
Load the user's permissions from a local file.
This method loads the specified user's command execution permissions from a local master permissions file (generated by the mercury2 user interface).
| PermissionsError | if the file can't be loaded for some reason. |
| May | throw PermissionsInvalidSchema if the permission settings file does not conform to the defined schema. |
| user_id | The ID of the user to load permissions for. |
|
private |
Saves the user command execution permission settings in the PermissionManager.
This callback saves the permissions for every user with permissions defined in permission settings.
| PermissionsUserNotFound | if the user originally indicated couldn't be located in the loaded permissions resource. |
| permission_settings | An array containing the JSON permission objects for users it includes. |
| user_id | The ID of the user that was initially queried for. |
|
private |
Updates the permissions for the indicated user.
This method downloads (or loads), validates, and saves the specified user's permission settings.
| Throws | PermissionsInvalidSchema if the dictionary defined in permission_settings does not conform to the permission settings schema, as checked by _validate_permissions(). |
| PermissionsUserNotFound | if the indicated user couldn't be located in the loaded permissions resource. |
| user_id | The ID of the user that the command permissions are for. |
|
private |
Validates the provided permission settings.
This method makes sure that the provided permission structure conforms to the defined JSON schema.
| Throws | PermissionsInvalidSchema if the dictionary defined in permission_settings does not conform to the permission settings schema. |
| Throws | PermissionsError if the raw permissions resource can't be parsed. |
| raw_permissions | A raw, unparsed, permissions resource file (either from net or local machine). |
| user_id | The ID of the user who's permissions are being queried for. |
| def hwm.network.security.permissions.PermissionManager.get_user_permissions | ( | self, | |
| user_id | |||
| ) |
Returns the permissions structure for the indicated user.
If the user does not have any permissions loaded, they will be downloaded/loaded in a thread and returned via a deferred. If the user does have cached permissions, they will be fired immediately into the returned deferred (and will get updated in the background if they are too old).
| Throws | PermissionsUserNotFound if the specified user doesn't have any permission settings saved. |
| user_id | The ID of the user to fetch permissions for. This refers to the UUID that was generated for the user, not their username. |
| def hwm.network.security.permissions.PermissionManager.purge_user_permissions | ( | self, | |
| age | |||
| ) |
Removes all old permission settings.
This method removes all permission settings entries older than the specified value. Once the permissions have been removed, applicable calls to get_user_permissions will fail and the permissions will be re-downloaded.
| age | Any permission entries older than age will be purged. The age is specified in seconds. |