Skip to content

Commit 2705cd4

Browse files
authored
feat: implement a method to override \the default connection params for the admin-ui (#1774)
1 parent df3df6a commit 2705cd4

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

docker-admin-ui/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FROM alpine:3.19
66

77
RUN apk update \
88
&& apk upgrade --available \
9-
&& apk add --no-cache tini openssl python3 py3-cryptography py3-psycopg2 nginx py3-grpcio \
9+
&& apk add --no-cache tini openssl python3 py3-cryptography py3-psycopg2 nginx py3-grpcio curl \
1010
&& apk add --no-cache --virtual .build-deps git
1111

1212
# =====
@@ -44,7 +44,7 @@ RUN cd /tmp/jans \
4444
&& cp ${JANS_SETUP_DIR}/schema/custom_schema.json /app/schema/ \
4545
&& cp ${JANS_SETUP_DIR}/schema/opendj_types.json /app/schema/
4646

47-
ENV FLEX_SOURCE_VERSION=a53727328019d8dba3c3c3daf01c5d4af0ad8b0e
47+
ENV FLEX_SOURCE_VERSION=3e17a7e152a5e527c4da4331b580c99e7c3a6692
4848

4949
RUN mkdir -p /app/templates/admin-ui
5050

docker-admin-ui/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ The following environment variables are supported by the container:
5454
- `CN_GOOGLE_SECRET_VERSION_ID`: Janssen secret version ID in Google Secret Manager. Defaults to `latest`, which is recommended.
5555
- `CN_GOOGLE_SECRET_NAME_PREFIX`: Prefix for Janssen secret in Google Secret Manager. Defaults to `jans`. If left `jans-secret` secret will be created.
5656
- `CN_GOOGLE_SECRET_MANAGER_PASSPHRASE`: Passphrase for Janssen secret in Google Secret Manager. This is recommended to be changed and defaults to `secret`.
57-
- `CN_TOKEN_SERVER_BASE_HOSTNAME`: Hostname of token server (default to `localhost`).
57+
- `CN_AUTH_BASE_URL`: Base URL of auth server (default to empty).
58+
- `CN_CONFIG_API_BASE_URL`: Base URL of config-api server (default to empty).
59+
- `CN_TOKEN_SERVER_BASE_URL`: Base URL of token server (default to empty).
5860
- `CN_TOKEN_SERVER_AUTHZ_ENDPOINT`: Authorization endpoint at token server (default to `/jans-auth/authorize.htm`).
5961
- `CN_TOKEN_SERVER_TOKEN_ENDPOINT`: Token endpoint at token server (default to `/jans-auth/restv1/token`).
6062
- `CN_TOKEN_SERVER_INTROSPECTION_ENDPOINT`: Introspection endpoint at token server (default to `/jans-auth/restv1/introspection`).

docker-admin-ui/scripts/bootstrap.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def __init__(self, manager):
6262
self.client = client_cls(manager)
6363

6464
def get_token_server_ctx(self):
65-
hostname = os.environ.get("CN_TOKEN_SERVER_BASE_HOSTNAME") or self.manager.config.get("hostname")
65+
hostname = self.manager.config.get("hostname")
66+
base_url = os.environ.get("CN_TOKEN_SERVER_BASE_URL") or f"https://{hostname}"
6667
authz_endpoint = os.environ.get("CN_TOKEN_SERVER_AUTHZ_ENDPOINT") or "/jans-auth/restv1/authorize"
6768
token_endpoint = os.environ.get("CN_TOKEN_SERVER_TOKEN_ENDPOINT") or "/jans-auth/restv1/token"
6869
introspection_endpoint = os.environ.get("CN_TOKEN_SERVER_INTROSPECTION_ENDPOINT") or "/jans-auth/restv1/introspection"
@@ -75,19 +76,22 @@ def get_token_server_ctx(self):
7576
return {
7677
"token_server_admin_ui_client_id": os.environ.get("CN_TOKEN_SERVER_CLIENT_ID") or self.manager.config.get("token_server_admin_ui_client_id"),
7778
"token_server_admin_ui_client_pw": read_from_file(pw_file),
78-
"token_server_authz_url": f"https://{hostname}{authz_endpoint}",
79-
"token_server_token_url": f"https://{hostname}{token_endpoint}",
80-
"token_server_introspection_url": f"https://{hostname}{introspection_endpoint}",
81-
"token_server_userinfo_url": f"https://{hostname}{userinfo_endpoint}",
79+
"token_server_base_url": base_url,
80+
"token_server_authz_url": f"{base_url}{authz_endpoint}",
81+
"token_server_token_url": f"{base_url}{token_endpoint}",
82+
"token_server_introspection_url": f"{base_url}{introspection_endpoint}",
83+
"token_server_userinfo_url": f"{base_url}{userinfo_endpoint}",
8284
}
8385

8486
@cached_property
8587
def ctx(self):
8688
salt = self.manager.secret.get("encoded_salt")
89+
hostname = self.manager.config.get("hostname")
8790

8891
ctx = {
89-
"hostname": self.manager.config.get("hostname"),
92+
"hostname": hostname,
9093
"adminui_authentication_mode": os.environ.get("GLUU_ADMIN_UI_AUTH_METHOD", "basic"),
94+
"jans_auth_base_url": os.environ.get("CN_AUTH_BASE_URL", f"https://{hostname}"),
9195
}
9296

9397
# admin-ui client for auth server
@@ -289,14 +293,20 @@ def resolve_conf_app(old_conf, new_conf):
289293
old_conf["oidcConfig"]["auiWebClient"]["additionalParameters"] = []
290294
should_update = True
291295

296+
# changes to auiBackendApiClient endpoints
297+
for endpoint in ["tokenEndpoint", "introspectionEndpoint"]:
298+
if old_conf["oidcConfig"]["auiBackendApiClient"][endpoint] != new_conf["oidcConfig"]["auiBackendApiClient"][endpoint]:
299+
old_conf["oidcConfig"]["auiBackendApiClient"][endpoint] = new_conf["oidcConfig"]["auiBackendApiClient"][endpoint]
300+
should_update = True
301+
292302
# finalized status and conf
293303
return should_update, old_conf
294304

295305

296306
def render_env_config(manager):
297307
hostname = manager.config.get("hostname")
298308
ctx = {
299-
"hostname": hostname,
309+
"config_api_base_url": os.environ.get("CN_CONFIG_API_BASE_URL", f"https://{hostname}"),
300310
}
301311

302312
with open("/app/templates/admin-ui/env-config.js") as fr:

docker-admin-ui/templates/admin-ui/auiConfiguration.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"oidcConfig": {
33
"auiWebClient": {
4-
"opHost": "https://%(hostname)s",
4+
"opHost": "%(jans_auth_base_url)s",
55
"clientId": "%(admin_ui_client_id)s",
66
"clientSecret": "%(admin_ui_client_encoded_pw)s",
77
"scopes": [
@@ -19,7 +19,7 @@
1919
"additionalParameters": []
2020
},
2121
"auiBackendApiClient": {
22-
"opHost": "https://%(hostname)s",
22+
"opHost": "%(token_server_base_url)s",
2323
"clientId": "%(token_server_admin_ui_client_id)s",
2424
"clientSecret": "%(token_server_admin_ui_client_encoded_pw)s",
2525
"tokenEndpoint": "%(token_server_token_url)s",
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const CONFIG_API_BASE_URL = "https://%(hostname)s/jans-config-api"
2-
const API_BASE_URL = "https://%(hostname)s/jans-config-api/admin-ui"
1+
const CONFIG_API_BASE_URL = "%(config_api_base_url)s/jans-config-api"
2+
const API_BASE_URL = "%(config_api_base_url)s/jans-config-api/admin-ui"
33

44
window.configApiBaseUrl = CONFIG_API_BASE_URL
55
window.apiBaseUrl = API_BASE_URL

0 commit comments

Comments
 (0)