Browse Source

feat: add new endpoints

pull/632/head
Alekey Kuznetsov 2 weeks ago
parent
commit
865aa54514
  1. 138
      CHANGELOG.md
  2. 105
      src/keycloak/keycloak_admin.py
  3. 2
      src/keycloak/urls_patterns.py

138
CHANGELOG.md

@ -1,140 +1,4 @@
## v5.1.2 (2025-01-26)
### Fix
- small bugs, use ruff as linter, added annotations
## v5.1.1 (2024-12-15)
### Fix
- retry upon 401
## v5.1.0 (2024-12-14)
### Feat
- get_client_all_sessions now supports pagination
- uma extra payload
- user profile metadata parameter for get_user method
- uma extra payload
### Fix
- check uma permissions with resource ID as well
- get group by path should not raise on 404
## v5.0.0 (2024-12-10)
## v4.7.3 (2024-11-29)
### Fix
- change to mounts (#622)
## v4.7.2 (2024-11-17)
### Fix
- Feature parity for `a_decode_token` and `decode_token` (#616)
## v4.7.1 (2024-11-13)
### Fix
- make sure to not call sync IO functions inside async functions (#615)
## v4.7.0 (2024-11-03)
### Feat
- add client scope client-specific role mappings (#605)
## v4.6.3 (2024-10-26)
### Fix
- Add optional Nonce parameter to the authorization URL requests (#606)
## v4.6.2 (2024-10-05)
### Fix
- add scopes to device auth (#599)
## v4.6.1 (2024-10-05)
### Fix
- changed sync get user id to async get user in create user async function (#600)
## v4.6.0 (2024-10-04)
### Feat
- Add the max_retries parameter (#598)
## v4.5.1 (2024-10-02)
### Fix
- Set client_credentials as grant_type also when x509 certificate is given (#597)
## v4.5.0 (2024-09-28)
### Feat
- add ability to remove composite client roles (#596)
## v4.4.0 (2024-09-14)
### Feat
- add matchingUri support for listing resources with wildcards (#592)
## v4.3.0 (2024-08-01)
### Feat
- allow the use of client certificates in all requests (#584)
## v4.2.3 (2024-07-24)
### Fix
- use a_public_key() in a_decode_token() instead of public_key() (#582)
## v4.2.2 (2024-07-16)
### Fix
- correctly pass query params in a_send_update_account and a_send_verify_email (#581)
## v4.2.1 (2024-07-11)
### Fix
- passing timeout values to ConnectionManager (#578)
## v4.2.0 (2024-06-22)
### Feat
- functions for updating resource permissions and getting associated policies for a permission (#574)
## v4.1.0 (2024-06-06)
### Feat
- Async feature (#566)
## v4.0.1 (2024-06-04)
### Fix
- Leeway config (#568)
## v4.0.0 (2024-04-27)
## Unreleased
### BREAKING CHANGE

105
src/keycloak/keycloak_admin.py

@ -3779,25 +3779,32 @@ class KeycloakAdmin:
:raises KeycloakPostError: when post requests are failed
"""
params_path = {"id": execution_id, "realm-name": self.connection.realm_name}
try:
if diff > 0:
for _i in range(diff):
_ = self.connection.raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_RAISE_PRIORITY.format(
**params_path,
),
data="{}",
)
elif diff < 0:
for _i in range(-diff):
_ = self.connection.raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_LOWER_PRIORITY.format(
**params_path,
),
data="{}",
)
except Exception as err:
raise KeycloakPostError from err
if diff > 0:
for _ in range(diff):
data_raw = self.connection.raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_RAISE_PRIORITY.format(
**params_path,
),
data="{}",
)
raise_error_from_response(
data_raw,
KeycloakPostError,
expected_codes=[HTTP_NO_CONTENT],
)
elif diff < 0:
for _ in range(-diff):
data_raw = self.connection.raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_LOWER_PRIORITY.format(
**params_path,
),
data="{}",
)
raise_error_from_response(
data_raw,
KeycloakPostError,
expected_codes=[HTTP_NO_CONTENT],
)
def create_authentication_flow_subflow(
self,
@ -3899,7 +3906,11 @@ class KeycloakAdmin:
urls_patterns.URL_ADMIN_FLOWS_EXECUTION.format(**params_path) + "/config",
data=json.dumps(payload),
)
return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[201])
return raise_error_from_response(
data_raw,
KeycloakPostError,
expected_codes=[HTTP_CREATED],
)
def update_authenticator_config(self, payload: dict, config_id: str) -> bytes:
"""
@ -10492,7 +10503,6 @@ class KeycloakAdmin:
KeycloakPostError,
expected_codes=[HTTP_NO_CONTENT],
)
return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[204])
async def a_change_execution_priority(self, execution_id: str, diff: int) -> None:
"""
@ -10505,25 +10515,32 @@ class KeycloakAdmin:
:raises KeycloakPostError: when post requests are failed
"""
params_path = {"id": execution_id, "realm-name": self.connection.realm_name}
try:
if diff > 0:
for _i in range(diff):
_ = self.connection.a_raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_RAISE_PRIORITY.format(
**params_path,
),
data="{}",
)
elif diff < 0:
for _i in range(-diff):
_ = self.connection.a_raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_LOWER_PRIORITY.format(
**params_path,
),
data="{}",
)
except Exception as err:
raise KeycloakPostError from err
if diff > 0:
for _ in range(diff):
data_raw = self.connection.a_raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_RAISE_PRIORITY.format(
**params_path,
),
data="{}",
)
raise_error_from_response(
data_raw,
KeycloakPostError,
expected_codes=[HTTP_NO_CONTENT],
)
elif diff < 0:
for _ in range(-diff):
data_raw = self.connection.a_raw_post(
urls_patterns.URL_AUTHENTICATION_EXECUTION_LOWER_PRIORITY.format(
**params_path,
),
data="{}",
)
raise_error_from_response(
data_raw,
KeycloakPostError,
expected_codes=[HTTP_NO_CONTENT],
)
async def a_create_execution_config(self, execution_id: str, payload: dict) -> bytes:
"""
@ -10541,10 +10558,14 @@ class KeycloakAdmin:
"""
params_path = {"id": execution_id, "realm-name": self.connection.realm_name}
data_raw = self.connection.a_raw_post(
urls_patterns.URL_ADMIN_FLOWS_EXECUTION.format(**params_path) + "/config",
urls_patterns.URL_ADMIN_FLOWS_EXECUTION_CONFIG.format(**params_path),
data=json.dumps(payload),
)
return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[201])
return raise_error_from_response(
data_raw,
KeycloakPostError,
expected_codes=[HTTP_CREATED],
)
async def a_update_authentication_flow(self, flow_id: str, payload: dict) -> bytes:
"""

2
src/keycloak/urls_patterns.py

@ -235,3 +235,5 @@ URL_AUTHENTICATION_EXECUTION_RAISE_PRIORITY = (
URL_AUTHENTICATION_EXECUTION_LOWER_PRIORITY = (
"realms/{realm-name}/authentication/executions/{id}/lower-priority"
)
URL_ADMIN_FLOWS_EXECUTION_CONFIG = URL_ADMIN_FLOWS_EXECUTION + "{id}/config"
Loading…
Cancel
Save