Skip to main content

Python utility package for verifying & decoding OKTA tokens

Project description

oktagon-python

PyPI

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.

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:

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

oktagon-python-0.0.14.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

oktagon_python-0.0.14-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file oktagon-python-0.0.14.tar.gz.

File metadata

  • Download URL: oktagon-python-0.0.14.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for oktagon-python-0.0.14.tar.gz
Algorithm Hash digest
SHA256 92ea3b63f8ac7865fedbb81ec1467c39dba2703d96b5528116b4c4c09364faec
MD5 cb228a35abfd04267e600171666a4105
BLAKE2b-256 d6178af02763a2043b560d8edef9ece2ab3cb5baaf7530b25d9fe8c3d15d2aa6

See more details on using hashes here.

File details

Details for the file oktagon_python-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for oktagon_python-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 d8a314baa2b5c6610e8614ecf62442c03f57bd51f16e01152621e7a49d8d45d1
MD5 7b0b6be67c3a564da7fdaba7cf9363cc
BLAKE2b-256 f07a029e3572b1c7b691531a2855417b0bec2a862f28fb884af55152cb6b3b95

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