Skip to main content

OpenID Connect JWT Token Snatcher

Project description

Authese

Authenticate through OpenID Connect and cache your JWT token in a file.

Example

from authese import get_token, EnvConfig, Environment

token = get_token(EnvConfig.from_env(Environment.STAGING))

Install

pip install authese

Info

There are 3 possible environments.

  • LOCAL
  • STAGING
  • PROD

Assuming STAGING

Create an EnvConfig object. Call get_token() and provide it with the EnvConfig object.

EnvConfig

- Personal access token

grant_type: '' Identical to grant_type: 'authorization_code'
This is the default authorization flow.
This will open a browser window where you can authenticate to the requested keycloak_url.

- Server to server

Depending if you set the grant_type: 'client_credentials'.
This will authenticate to the requested keycloak_url using the client credentials.

Cache

Once authenticated, your token will be cached at /tmp/authese-cache.dat
Subsequent calls to get_token() will use the cached token.
When the token expires it will be deleted and you must authenticate again.

To force reauthentication just remove the /tmp/authese-cache.dat file.

Config

local:
staging:
  keycloak_url: 'https://<openid-host>/realms/<realm>/protocol/openid-connect'
  grant_type: '<authorization_code | client_credentials>'
  client_id: '<client_id>'
  client_secret: '<client_secret>'
  redirect_host: 'http://127.0.0.1'
  redirect_port: 9981
  scopes:
    - 'email'
    - 'profile'
prod:
  keycloak_url: 'https://<openid-host>/realms/<realm>/protocol/openid-connect'
  grant_type: '<authorization_code | client_credentials>'
  client_id: '<client_id>'
  client_secret: '<client_secret>'
  redirect_host: 'http://127.0.0.1'
  redirect_port: 9981
  scopes:
    - 'email'
    - 'profile'

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

authese-0.1.6.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file authese-0.1.6.tar.gz.

File metadata

  • Download URL: authese-0.1.6.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for authese-0.1.6.tar.gz
Algorithm Hash digest
SHA256 6b4e2fe83b9190f02c7139deacc6248a96fcc956dcd09a67d7a4af6c7b80397c
MD5 03742f3e15dfb5504a967c970cf1e7e8
BLAKE2b-256 1808d0a0c04f3083008ef03c6d87df6aae3c7902239f6a7e88a32d3ea68e9908

See more details on using hashes here.

Provenance

The following attestation bundles were made for authese-0.1.6.tar.gz:

Publisher: build-and-publish.yml on adhese/authese

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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