Skip to content

Commit aee22c4

Browse files
authored
fix: Allow config of WebOrigins & RedirectUris (#4444)
1 parent 5163a0f commit aee22c4

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

helm-chart/renku/templates/setup-job-keycloak-realms.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ spec:
109109
value: "false"
110110
- name: NOTEBOOKS_KC_CLIENT_OAUTH_FLOW
111111
value: "authorization_code"
112+
- name: NOTEBOOKS_KC_CLIENT_EXTRA_REDIRECT_URIS
113+
value: {{ .Values.notebooks.oidc.extraRedirectUris | quote }}
114+
- name: NOTEBOOKS_KC_CLIENT_EXTRA_WEB_ORIGINS
115+
value: {{ .Values.notebooks.oidc.extraWebOrigins | quote }}
112116
- name: SWAGGER_KC_CLIENT_ID
113117
value: swagger
114118
- name: SWAGGER_KC_CLIENT_PUBLIC

helm-chart/renku/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,16 @@ notebooks:
879879
tokenUrl:
880880
authUrl:
881881
allowUnverifiedEmail: false
882+
## This value is a yaml string of a json list of URIs strings, i.e.
883+
## '["https://domain-a.example.org/*", "https://domain-b.example.net/*"]'
884+
## Each URI should follow the format expected by Keycloak in the Redirect
885+
## URIs field of a keycloak client.
886+
extraRedirectUris: '[]'
887+
## This value is a yaml string of a json list of URIs strings, i.e.
888+
## '["https://domain-a.example.org/*", "https://domain-b.example.net/*"]'
889+
## Each URI should follow the format expected by Keycloak in the Web Origins
890+
## field of a keycloak client.
891+
extraWebOrigins: '[]'
882892
sessionIngress:
883893
host:
884894
## If you want to use the default cluster tls cert, set the flag below to true.

scripts/init-realm/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class OIDCClient:
9393
service_account_roles: List[str] = field(default_factory=list)
9494
service_account_realm_roles: List[str] = field(default_factory=list)
9595
public_client: bool = False
96+
client_extra_web_origins: List[str] = field(default_factory=list)
97+
client_extra_redirect_uris: List[str] = field(default_factory=list)
9698

9799
def __post_init__(self):
98100
self.base_url = self.base_url.rstrip("/")
@@ -163,8 +165,8 @@ def to_dict(self) -> Dict[str, Any]:
163165
"baseUrl": self.base_url,
164166
"publicClient": self.public_client,
165167
"attributes": self.attributes,
166-
"redirectUris": [self.base_url + "/*"],
167-
"webOrigins": [self.base_url + "/*"],
168+
"redirectUris": [self.base_url + "/*"] + self.client_extra_redirect_uris,
169+
"webOrigins": [self.base_url + "/*"] + self.client_extra_web_origins,
168170
"protocolMappers": default_protocol_mappers
169171
+ [
170172
{
@@ -207,6 +209,12 @@ def from_env(cls, prefix: str = "RENKU_KC_CLIENT_") -> "OIDCClient":
207209
service_account_realm_roles=json.loads(
208210
os.environ.get(f"{prefix}SERVICE_ACCOUNT_REALM_ROLES", "[]")
209211
),
212+
client_extra_redirect_uris=json.loads(
213+
os.environ.get(f"{prefix}EXTRA_REDIRECT_URIS", "[]")
214+
),
215+
client_extra_web_origins=json.loads(
216+
os.environ.get(f"{prefix}EXTRA_WEB_ORIGINS", "[]")
217+
)
210218
)
211219

212220

0 commit comments

Comments
 (0)