Skip to main content

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

rbac-utils-0.0.3.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

rbac_utils-0.0.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file rbac-utils-0.0.3.tar.gz.

File metadata

  • Download URL: rbac-utils-0.0.3.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

Hashes for rbac-utils-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b6930b53e3a675f928d8850fa753fc2730162b6951dfbc0b7d616485e8cfdfc8
MD5 9e0b0dbb2bec39c7915438b5389a00b7
BLAKE2b-256 7a6342cfca4427198dcea23a1315baf72793fbe3e1ab8d9b883d7f790a983b78

See more details on using hashes here.

File details

Details for the file rbac_utils-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: rbac_utils-0.0.3-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

Hashes for rbac_utils-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 123bd0be81e659cd88a45712bcd100862edee8cf5bfa82a8c65b926cb8e56943
MD5 780236c3d9f22ef40a4af8104d84f671
BLAKE2b-256 c561a296427c33aabdb60ac3e49f2a4e8e8ecff03d33d12d2b460e9d8de8b112

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page