cidaas interceptor for Python (django)

Video tutorial explaining the simple steps to integerate the cidaas interceptor into your Python (django) applications:

The steps here will guide you to integrate the cidaas-interceptor into the Python (django).

A simple interceptor(Decorator in python terms) to check the validity of the access token provided in the request header and also few other decorators.

Click here for Sample Project.

Installation

pip install cidaas_interceptor

Config

Set an environment variable called 'URL_INFO' which will give path to a JSON file which contain 'user_info_by_token', the url against which the token validity need to be checked.

Required Property File

vim cidaas_urls_settings.json
{'user_info_by_token': "yourbaseurl/token/userinfobytoken"}

Working

First the view need to be decorated accordingly by any of the following:

  • validate_token: checks the validity of the token based on scope and roles.
  • permit_all: permit all regardless of the token provided.
  • deny_all: deny all regardless of the token provided.

Then for every request to view, according to decorator action will be taken.

Usage

from cidaas_interceptor import validate_token, permit_all, deny_all
#Basic functioning of interceptor

@validate_token(roles=None, scope=None)
def index(request, *args, **kwargs):
    # your code.

Here we can see first we have imported the decorator from the package. After that the view is decorated using the appropriate decorator.

Check Roles

@validate_token(roles="HR")
def index(request, *args, **kwargs):
    # your code.

Check Roles and Scopes

@validate_token(roles="HR", scope="holidaylist:read")
def index(request, *args, **kwargs):
    # your code.

Deny All

@deny_all
def index(request, *args, **kwargs):
    # your code.

Permit All

@permit_all
def index(request, *args, **kwargs):
    # your code



results matching ""

    No results matching ""