Keycloak integration Class

class secconkeycloak.Keycloak(url)

Bases: object

get_token(user: str, pwd: str) str

Takes the admin username and password and returns a session token for future Bearer authentication

Returns the token, or raises an exception for the caller to catch

create_client(client: str, url: str, token: str, realm: str) None

POSTs a new client named according to the componentName for a new component

Returns nothing, or raises an exception for the caller to catch

del_client(client: str, token: str, realm: str) None

DELETEs a client

Returns nothing, or raises an exception for the caller to catch

get_client_list(token: str, realm: str) dict

GETs a list of clients in the realm to ensure there is a client to match the componentName

Returns a dictonary of clients and ids or raises an exception for the caller to catch

add_role(role: str, client_id: str, token: str, realm: str) None

POST new roles to the right client in the right realm in Keycloak

Returns nothing or raises an exception for the caller to catch

del_role(role: str, client: str, token: str, realm: str) None

DELETE removed roles from the right client in the right realm in Keycloak

Returns nothing or raises an exception for the caller to catch

add_role_to_user(username: str, role: str, client: str, token: str, realm: str) None

POST client role assignment to user in realm in Keycloak

Returns nothing or raises an exception for the caller to catch