Skip to content

Commit 347083a

Browse files
author
Arron Atchison
committed
feat(tb-dev): add the tbpro OIDC clients for Send
Send on EKS tb-dev needs two tbpro clients (platform-infrastructure#712, part of the Send migration #695). Neither exists today -- verified: no send* client in the thunderbird/accounts realm import (11 clients, appointment pair present) and none codified here. Two clients, mirroring the thunderbird-appointment pair, because Send has two distinct OIDC roles (verified in tbpro-add-on packages/send): - thunderbird-send-frontend PUBLIC: the SPA does auth-code + PKCE via oidc-client-ts (reads APP_OIDC_CLIENT_ID) - thunderbird-send-backend CONFIDENTIAL: validates bearer tokens by RFC 7662 introspection (reads OIDC_CLIENT_ID + OIDC_CLIENT_SECRET) A public client cannot introspect, so one shared client would not work. Under Pattern C the SPA and API share one origin (https://send.tb-dev.thunderbird.dev), so both clients use that single redirect/web-origin host -- there is no separate send-backend host on EKS. Wiring (the file alone would be inert): - apply-client-config.sh: CONFIG_FILE -> CONFIG_FILES, now passing both imports to config-cli's comma-separated IMPORT_FILES_LOCATIONS. Unchanged otherwise: still no-delete (never touches other tbpro clients), cache disabled so it reconciles on every start, same retry loop. - kustomization.yaml: ship tbpro-send-clients.yaml in the keycloak-realm-config ConfigMap. Verified the rendered ConfigMap has both keys and /config is mounted as a whole directory, so the new path resolves. Because this reconciles on every Keycloak start, a Neon branch reset self-repairs these clients with no manual kcadm step. The backend client's SECRET is deliberately not set here (config-cli would need it in plaintext). Keycloak generates one on creation; it must be copied into the mzla/tb-dev/send bundle as OIDC_CLIENT_SECRET (platform-infrastructure#711). Refs platform-infrastructure#712, #695
1 parent 0ed19af commit 347083a

3 files changed

Lines changed: 69 additions & 2 deletions

File tree

overlays/tb-dev/keycloak/realm-config/apply-client-config.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616

1717
set -uo pipefail
1818

19-
CONFIG_FILE='/config/tbpro-accounts-client.yaml'
19+
# Both tbpro client-config imports. config-cli's IMPORT_FILES_LOCATIONS takes a
20+
# comma-separated list, so adding a file here is all that is needed -- but note the
21+
# ConfigMap in kustomization.yaml must ship it too, or the path will not exist.
22+
# tbpro-accounts-client.yaml : the thunderbird-accounts client
23+
# tbpro-send-clients.yaml : the Send SPA + backend pair (#712)
24+
CONFIG_FILES='/config/tbpro-accounts-client.yaml,/config/tbpro-send-clients.yaml'
2025
CONFIG_CLI_JAR='/opt/keycloak/keycloak-config-cli.jar'
2126
# Management interface (health/metrics) -- enabled via KC_HEALTH_ENABLED=true.
2227
HEALTH_PORT="${KC_HTTP_MANAGEMENT_PORT:-9000}"
@@ -55,7 +60,7 @@ export KEYCLOAK_REALM=master
5560
export KEYCLOAK_GRANTTYPE=client_credentials
5661
export KEYCLOAK_CLIENTID="${KEYCLOAK_ADMIN_CLIENT_ID:-tb-accounts-admin}"
5762
export KEYCLOAK_CLIENTSECRET="${KEYCLOAK_ADMIN_CLIENT_SECRET}"
58-
export IMPORT_FILES_LOCATIONS="${CONFIG_FILE}"
63+
export IMPORT_FILES_LOCATIONS="${CONFIG_FILES}"
5964
export IMPORT_VARSUBSTITUTION_ENABLED=false
6065
# Reconcile on every start (config-cli otherwise checksums the file and skips, so
6166
# drift from a reset would never be repaired). The import is idempotent.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# keycloak-config-cli import: tb-dev env-specific config for the two tbpro OIDC
2+
# clients Thunderbird Send needs (platform-infrastructure#712, part of the Send
3+
# EKS migration #695).
4+
#
5+
# Reconciled by apply-client-config.sh on every Keycloak start, in no-delete mode
6+
# -- config-cli only ADDS/UPDATES these clients and never deletes other tbpro
7+
# clients/users/flows. Because it re-runs on every start, a Neon branch reset
8+
# (which reverts the realm to the stage clone and wipes these) self-repairs with
9+
# no manual kcadm step, exactly like tbpro-accounts-client.yaml.
10+
#
11+
# TWO clients, mirroring the thunderbird-appointment pair, because Send has two
12+
# distinct OIDC roles (verified in tbpro-add-on packages/send):
13+
# - the SPA is a PUBLIC client using the auth-code flow via oidc-client-ts
14+
# (frontend reads VITE_/APP_OIDC_CLIENT_ID);
15+
# - the backend is a CONFIDENTIAL client that validates bearer tokens by
16+
# RFC 7662 introspection (reads OIDC_CLIENT_ID + OIDC_CLIENT_SECRET).
17+
# A public client cannot introspect, so one shared client will not work.
18+
#
19+
# Pattern C: the SPA and the API share ONE origin
20+
# (https://send.tb-dev.thunderbird.dev), so the redirect/web-origin host is the
21+
# same for both. There is no separate send-backend host on EKS.
22+
realm: tbpro
23+
clients:
24+
# --- public SPA client (browser auth-code + PKCE) ---
25+
- clientId: thunderbird-send-frontend
26+
name: Thunderbird Send (SPA, tb-dev)
27+
enabled: true
28+
publicClient: true
29+
standardFlowEnabled: true
30+
directAccessGrantsEnabled: false
31+
serviceAccountsEnabled: false
32+
rootUrl: "https://send.tb-dev.thunderbird.dev"
33+
baseUrl: "/"
34+
redirectUris:
35+
# oidc-client-ts returns the browser to the SPA origin after login/logout.
36+
- "https://send.tb-dev.thunderbird.dev/*"
37+
webOrigins:
38+
- "https://send.tb-dev.thunderbird.dev"
39+
attributes:
40+
# validate post-logout redirects against the registered redirect URIs
41+
"post.logout.redirect.uris": "+"
42+
# public client => PKCE is required, not optional
43+
"pkce.code.challenge.method": "S256"
44+
45+
# --- confidential backend client (RFC 7662 token introspection) ---
46+
# The secret is NOT set here: config-cli would need it in plaintext, and the
47+
# backend reads it from the mzla/tb-dev/send Secrets Manager bundle via ESO as
48+
# OIDC_CLIENT_SECRET. Keycloak generates a secret on creation; it must be copied
49+
# into that bundle once (platform-infrastructure#711).
50+
- clientId: thunderbird-send-backend
51+
name: Thunderbird Send (backend introspection, tb-dev)
52+
enabled: true
53+
publicClient: false
54+
standardFlowEnabled: true
55+
directAccessGrantsEnabled: false
56+
serviceAccountsEnabled: false
57+
rootUrl: "https://send.tb-dev.thunderbird.dev"
58+
redirectUris:
59+
- "https://send.tb-dev.thunderbird.dev/*"
60+
webOrigins:
61+
- "https://send.tb-dev.thunderbird.dev"

overlays/tb-dev/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ configMapGenerator:
1919
- name: keycloak-realm-config
2020
files:
2121
- keycloak/realm-config/tbpro-accounts-client.yaml
22+
- keycloak/realm-config/tbpro-send-clients.yaml
2223
- name: keycloak-realm-config-scripts
2324
files:
2425
- keycloak/realm-config/apply-client-config.sh

0 commit comments

Comments
 (0)