mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-02-14 10:26:28 +00:00
update to make this work for both local openid and keycloak again (#2197)
* update to make this work for both local openid and keycloak again * Update spiffworkflow-backend/bin/get_token Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix coderabbit --------- Co-authored-by: burnettk <burnettk@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
41e23cf74c
commit
6c0acaea1e
@ -19,7 +19,7 @@ def get_argv(index: int, default: Any = None) -> Any:
|
|||||||
|
|
||||||
username = get_argv(1, "admin")
|
username = get_argv(1, "admin")
|
||||||
password = get_argv(2, "admin")
|
password = get_argv(2, "admin")
|
||||||
realm_name = get_argv(3, "spiffworkflow")
|
realm_name = get_argv(3, "spiffworkflow-local")
|
||||||
|
|
||||||
OPEN_ID_CODE = ":this_is_not_secure_do_not_use_in_production"
|
OPEN_ID_CODE = ":this_is_not_secure_do_not_use_in_production"
|
||||||
|
|
||||||
@ -38,9 +38,15 @@ if openid_token_url is None:
|
|||||||
raise Exception("Could not determine openid url based on backend url")
|
raise Exception("Could not determine openid url based on backend url")
|
||||||
env_domain = match.group(1)
|
env_domain = match.group(1)
|
||||||
keycloak_base_url = "https://keycloak.${env_domain}"
|
keycloak_base_url = "https://keycloak.${env_domain}"
|
||||||
elif "localhost:7000" in backend_base_url:
|
import urllib.parse
|
||||||
keycloak_base_url = "http://localhost:7000"
|
|
||||||
openid_token_url = f"{keycloak_base_url}/realms/{realm_name}/protocol/openid-connect/token"
|
token_path = "/protocol/openid-connect/token"
|
||||||
|
if "/realms" in keycloak_base_url:
|
||||||
|
openid_token_url = f"{keycloak_base_url}{token_path}"
|
||||||
|
else:
|
||||||
|
# Sanitize realm_name to prevent path traversal
|
||||||
|
safe_realm = urllib.parse.quote(realm_name, safe="")
|
||||||
|
openid_token_url = f"{keycloak_base_url}/realms/{safe_realm}{token_path}"
|
||||||
else:
|
else:
|
||||||
openid_token_url = f"{backend_base_url}/openid/token"
|
openid_token_url = f"{backend_base_url}/openid/token"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user