Skip to main content

A facade package used to perform required keycloak actions which will be made available throughout each Orodha service.

Project description

Orodha-Keycloak

This package is a facade interfacing with python-keycloak used by Orodha services in order to make requests to a keycloak server.

Requirements

Along with the requirements in the requirements.txt file, in order for this package to function properly you need to configure keycloak in a certain way.

Here is a tutorial for setting up keycloak clients and service accounts with the keycloak CLI.

The long and short of it is that in order for this package to work you need to set up a keycloak Realm, that has at least one client which you configure to use a confidential access type and secret_key, along with the ability to use service accounts.

Once you do this, you have to give you service account the required permissions for

  • creating users
  • deleting users
  • querying users
  • decoding tokens

Usage

In order to download this package, you simply have to run the command

python3 -m pip install orodha-keycloak

After downloading the package you can import it to a file with the statement

from orodha_keycloak import OrodhaKeycloakClient

You can find further descriptions of this class in the following section as well as the method class and method docstrings for the class.

Description

This package contains one main class, OrodhaKeycloakClient. The class expects the following arguments upon instantiation:

  • server_url: the main url for our keycloak server. example: http://keycloak:{port}/auth/
  • realm_name: The name of the keycloak realm that you want to interfacing with.
  • client_id: The client_id of the keycloak client for your service worker you want to use.

The next three are special. in order to create a connection you either have to pass a client_secret_key to the class, or you have to pass a username and a password to the class. If you do not have one of these two choices you will get an error.

  • client_secret_key: Obtained from keycloak, used for connecting securely to the keycloak client.
  • username / password: The username and password of a keycloak user that you want to log in as in order to take actions on the keycloak realm.

The current methods available on this class are:

  • add_user: Adds a user to keycloak with a password.
  • delete_user: Deletes a keycloak user with a given user_id.
  • get_user: Takes either a user_id or a token and returns the user if they exist.
{'id': 'ddcbcb65-4515-4e72-8b0e-9e844cb7f06a', 'createdTimestamp': 1695143223350, 'username': 'demoadmin', 'enabled': True, 'totp': False, 'emailVerified': False, 'disableableCredentialTypes': [], 'requiredActions': [], 'notBefore': 0, 'access': {'manageGroupMembership': True, 'view': True, 'mapRoles': True, 'impersonate': True, 'manage': True}}
  • decode_jwt: Small helper function which decodes a JWT token using the client connection.

but more may be added in future versions.

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

orodha_keycloak-1.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orodha_keycloak-1.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file orodha_keycloak-1.1.0.tar.gz.

File metadata

  • Download URL: orodha_keycloak-1.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for orodha_keycloak-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e18a55b9050a90d8d8586f2fde1a059880d181a964ce8c8d5beee87f463d01aa
MD5 e98c7faa4b7e7d918ddde6fa617d5d74
BLAKE2b-256 daf8b8819278b2019bb570b20137947e949582be565bfc83541dfe21b5106efa

See more details on using hashes here.

File details

Details for the file orodha_keycloak-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for orodha_keycloak-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a1cb5b1c612fd56de9d8374b2125d708fbd73ac5c6286984c5235d1555de7f1
MD5 16dc02d9d45b89cdd7c194eb599898b1
BLAKE2b-256 905c36ec2f8b4c88c924f586cb14e7dd94f7da335ed63559939bd28e65fb5118

See more details on using hashes here.

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