Skip to main content

Django Ninja package to integrate keycloak authentication

Project description

django-ninja-keycloak

For review- see https://gitlab.com/django-ninja/django-ninja-keycloak

django-ninja-keycloak is a not official Django Ninja package to providing easy to use bearer token or basic auth authentication with django ninja flow

Installation

Via Pypi Package:

$ pip install django-ninja-keycloak

or

$ pipenv install django-ninja-keycloak

Dependencies

django-ninja-keycloak depends on:

Bug reports

Please report bugs and feature requests at https://gitlab.com/django-ninja/django-ninja-keycloak/issues

Usage

Bearer Auth

keycloak_bearer_auth = KeycloakAuthBearer('https://keyclaokhost/auth/',
                                         'client_id',
                                         'realm_name',
                                         'client_secret_key',
                                         'algorithm',            # optionnal  default='RS256'
                                         options,                # optionnal  default= {"verify_signature": True, "verify_aud": True, "verify_exp": True}
                                         roles)                  # optionnal  default= []

@api.get("/bearer", auth=keycloak_bearer_auth)
def bearer(request):
    return {"token": request.auth}`

Basic Auth

keycloak_basic_auth = KeycloakBasicAuth('https://keyclaokhost/auth/',
                                         'client_id',
                                         'realm_name',
                                         'client_secret_key',
                                         'algorithm',            # optionnal  default='RS256'
                                         options,                # optionnal  default= {"verify_signature": True, "verify_aud": True, "verify_exp": True}
                                         roles)                  # optionnal  default= []

@api.get("/basic", auth=keycloak_basic_auth)
def bearer(request):
    return {"token": request.auth}`

Request.auth payload

    {
        "userInfo": {
            "email_verified": '',
            "preferred_username": '',
            "name": '',
            "given_name": '',
            "family_name": '',
            "email": '',
            "sub": '',
        },
        "roles": []
    }

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

django_ninja_keycloak-0.0.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

django_ninja_keycloak-0.0.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file django_ninja_keycloak-0.0.5.tar.gz.

File metadata

  • Download URL: django_ninja_keycloak-0.0.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for django_ninja_keycloak-0.0.5.tar.gz
Algorithm Hash digest
SHA256 151fa73cc160478d9108cf96c37b538ca3d154abc480ede7b9d3faf6e0e8aac9
MD5 e74d9355f33ce519f408837f2ddf998a
BLAKE2b-256 7b93a918c24766113d258244bbb3a73a5b6a7cebb72ec7a7f5dfec2307a6f356

See more details on using hashes here.

File details

Details for the file django_ninja_keycloak-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: django_ninja_keycloak-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for django_ninja_keycloak-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 18b6daef6c611d458e211fabbf053c61002f3c776c0200b408d3a34dc03ec36a
MD5 1c5e04527d1175e5219c7a879c41aa37
BLAKE2b-256 fb4c76b87f6a1f5235da4a3402f84af5a21fb74867b83e27a916f0399a916a94

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