Utilities for RBAC system
Project description
RABC Utils
This library provides utility functions for RBAC system.
APIs
Utils(token)
- validate_token() -> boolean
- get_user_roles() -> [user]
- is_user_role_present(role) -> boolean
- get_user_details() -> {}
- validate_with_server(timeout_seconds=20) -> boolean
EXAMPLE
Installing the lib
Install the lib with pip install command, supply the flags as below to specify the address of our private ldc_packages index.
pip install rbac-utils -i http://13.235.135.2:3141/dev/ldc_packages --trusted-host 13.235.135.2
Initialise the utils class:
Start by creating an instance of Utils class. Initialise it with a token string.
rbac_utils = Utils(token)
Validating A Token Locally:
Ensures valid 'nbf' claim, 'exp' claim and RBAC signature on the given token.
is_valid = rbac_utils.validate_token()
Validating A Token From Server:
Ensures valid 'nbf' claim, 'exp' claim and RBAC signature on the given token. Also checks if the token has been invalidated in the RBAC due to other reasons such as change in user's properties that are part of the token payload (Eg: roles, permissions, etc)
is_valid = rbac_utils.validate_with_server()
Getting User Roles From Token:
Get the list of roles defined in the token.
roles = rbac_utils.get_user_roles()
Checking For A Role On The Token:
Check if the given roles is present in the token.
is_role_present = rbac_utils.is_user_role_present('OPS')
Obtaining User Details From A Token:
Obtain user details such (user_id, email and mobile_number) from the token.
user_details = rbac_utils.get_user_details()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rbac-utils-0.0.2.tar.gz
.
File metadata
- Download URL: rbac-utils-0.0.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d62c7a9eaf641ca43bf344ad39cf800386e1e6744779cb49968b0f5ea083b9e3 |
|
MD5 | a55df3c16629cb7bada6a38a9120a1e4 |
|
BLAKE2b-256 | 766f5563603e2916527183f240d47cc4657c45addfb070836898526bfce2dbaf |
File details
Details for the file rbac_utils-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: rbac_utils-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09b65c1a8e4366bc168ed6a39cf6bf16ddfbb4baf8e01607f9e17116f0f77dcb |
|
MD5 | fc39392ea8c14e37f9b8ec4c0deba2d3 |
|
BLAKE2b-256 | d10b8e44d158cceadaf6d2db1e4dd7ee6651e70754704f147be2d9853dbbab23 |