Oktagon Python 0.0.18 | Coderz Repository

oktagon-python 0.0.18

Last updated:

0 purchases

oktagon-python 0.0.18 Image
oktagon-python 0.0.18 Images

Free

Languages

Categories

Add to Cart

Description:

oktagonpython 0.0.18

oktagon-python

This python package is a tiny utility for verifying & decoding OKTA tokens in python
backend services.
Installation
pip install oktagon-python

Getting Started
Let's say you have /consignments REST API endpoint which you'd like to make accessible
only by logistics OKTA group. Then you would write something like this:
import os

from oktagon_python.authorisation import AuthorisationManager
from starlette.requests import Request

auth_manager = AuthorisationManager(
service_name="your_service_name",
okta_issuer=os.environ.get("OKTAGON_OKTA_ISSUER"),
okta_audience=os.environ.get("OKTAGON_OKTA_AUDIENCE"),
)

async def is_authorised(request: Request):
return await auth_manager.is_user_authorised(
allowed_groups=["logistics"],
resource_name="consignments",
cookies=request.cookies
)

This will create an AuthorisationManager instance that will check user's
authorisation.
Getting user's email
There is get_user_email async method on AuthorisationManager to retrieve user's email. Usage:
from starlette.requests import Request

cookies: Request.cookies = request.cookies
email = await auth_manager.get_user_email(cookies)

Contributing
git clone https://github.com/madedotcom/oktagon-python.git
cd oktagon-python
make install
make tests

This will install all the dependencies (including dev ones) and run the tests.
Run the formatters/linters
make pretty

Will run all the formatters and linters (black, isort and pylint) in write mode.
make pretty-check

Will run the formatters and linters in check mode.
You can also run them separtly with make black, make isort, make pylint.
Realeses
Merging a PR into the main branch will trigger the GitHub release workflow.
The following GitHub actions will be triggered:

github-tag-action will bump a new
tag with patch version by default. Add #major or #minor to the merge commit
message to bump a different tag;
gh-action-pypi-publish will push the
newly built package on PyPI;
action-automatic-releases
will create the GitHub release and tag it with latest as well.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.