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.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

rbac_utils-0.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rbac-utils-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a4da372f67c312b49183d3e1b7126cc2f3f9d7c30849f0993b7143a44e294480
MD5 a6e9b73809c28b5b519a0cbe6b202124
BLAKE2b-256 3833e2e05ca7e54becb1b7571bffe56eddf96cd2802d98e6491524e5d0b3cb2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rbac_utils-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b4f810ccce3331effcdc0e6f1012a5abf11faa98695623721840fb2a577010d
MD5 b2ed96e251e9345fac9e4eb3e28922d3
BLAKE2b-256 0d546f4b01443f71dffb416827f560e3bbdb31ee50473459fbf70c7d15c6357c

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