keycloak.keycloak_uma
¶
Keycloak UMA module.
The module contains a UMA compatible client for keycloak: https://docs.kantarainitiative.org/uma/wg/rec-oauth-uma-federated-authz-2.0.html
Module Contents¶
Classes¶
Keycloak UMA client. |
- class keycloak.keycloak_uma.KeycloakUMA(server_url, realm_name, verify=True, custom_headers=None, proxies=None, timeout=60)[source]¶
Keycloak UMA client.
- Parameters:
server_url – Keycloak server url
client_id – client id
realm_name – realm name
client_secret_key – client secret key
verify – True if want check connection SSL
custom_headers – dict of custom header to pass to each HTML request
proxies – dict of proxies to sent the request by.
timeout – connection timeout in seconds
- property uma_well_known[source]¶
Get the well_known UMA2 config.
- Returns:
It lists endpoints and other configuration options relevant
- Return type:
dict
- static format_url(url, **kwargs)[source]¶
Substitute url path parameters.
Given a parameterized url string, returns the string after url encoding and substituting the given params. For example, format_url(“https://myserver/{my_resource}/{id}”, my_resource=”hello world”, id=”myid”) would produce https://myserver/hello+world/myid.
- Parameters:
url (str) – url string to format
kwargs (dict) – dict containing kwargs to substitute
- Returns:
formatted string
- Return type:
str
- resource_set_create(token, payload)[source]¶
Create a resource set.
Spec https://docs.kantarainitiative.org/uma/rec-oauth-resource-reg-v1_0_1.html#rfc.section.2.2.1
ResourceRepresentation https://www.keycloak.org/docs-api/20.0.0/rest-api/index.html#_resourcerepresentation
- Parameters:
token (str) – client access token
payload (dict) – ResourceRepresentation
- Returns:
ResourceRepresentation with the _id property assigned
- Return type:
dict
- resource_set_update(token, resource_id, payload)[source]¶
Update a resource set.
Spec https://docs.kantarainitiative.org/uma/rec-oauth-resource-reg-v1_0_1.html#update-resource-set
ResourceRepresentation https://www.keycloak.org/docs-api/20.0.0/rest-api/index.html#_resourcerepresentation
- Parameters:
token (str) – client access token
resource_id (str) – id of the resource
payload (dict) – ResourceRepresentation
- Returns:
Response dict (empty)
- Return type:
dict
- resource_set_read(token, resource_id)[source]¶
Read a resource set.
Spec https://docs.kantarainitiative.org/uma/rec-oauth-resource-reg-v1_0_1.html#read-resource-set
ResourceRepresentation https://www.keycloak.org/docs-api/20.0.0/rest-api/index.html#_resourcerepresentation
- Parameters:
token (str) – client access token
resource_id (str) – id of the resource
- Returns:
ResourceRepresentation
- Return type:
dict
- resource_set_delete(token, resource_id)[source]¶
Delete a resource set.
Spec https://docs.kantarainitiative.org/uma/rec-oauth-resource-reg-v1_0_1.html#delete-resource-set
- Parameters:
token (str) – client access token
resource_id (str) – id of the resource
- Returns:
Response dict (empty)
- Return type:
dict
- resource_set_list_ids(token)[source]¶
List all resource set ids.
Spec https://docs.kantarainitiative.org/uma/rec-oauth-resource-reg-v1_0_1.html#list-resource-sets
- Parameters:
token (str) – client access token
- Returns:
List of ids
- Return type:
List[str]
- resource_set_list(token)[source]¶
List all resource sets.
Spec https://docs.kantarainitiative.org/uma/rec-oauth-resource-reg-v1_0_1.html#list-resource-sets
ResourceRepresentation https://www.keycloak.org/docs-api/20.0.0/rest-api/index.html#_resourcerepresentation
- Parameters:
token (str) – client access token
- Yields:
Iterator over a list of ResourceRepresentations
- Return type:
Iterator[dict]