Skip to content

Commit b799fcc

Browse files
authored
fix(auth): harden OIDC trust root retrieval (#3332)
* fix(auth): harden OIDC trust root retrieval Signed-off-by: Mrunal Patel <mrunalp@gmail.com> * fix(e2e): pass OIDC HTTP acknowledgement value Signed-off-by: Mrunal Patel <mrunalp@gmail.com> --------- Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
1 parent c195e23 commit b799fcc

22 files changed

Lines changed: 757 additions & 57 deletions

File tree

‎.agents/skills/helm-dev-environment/SKILL.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,19 @@ Key Helm values:
256256

257257
### Keycloak OIDC
258258

259-
One-time setup — only needed once per cluster lifetime:
259+
Initial setup — rerun it whenever you want to rotate the development CA:
260260

261261
```bash
262262
mise run keycloak:k8s:setup
263263
```
264264

265265
This deploys Keycloak (`quay.io/keycloak/keycloak:24.0`) into the `keycloak` namespace,
266-
imports the openshell realm from `scripts/keycloak-realm.json`, and prints a port-forward
267-
command for acquiring tokens from the CLI.
266+
imports the openshell realm from `scripts/keycloak-realm.json`, generates a short-lived
267+
development TLS certificate, and publishes its trust anchor as the
268+
`openshell-keycloak-ca` ConfigMap in the OpenShell namespace. The command prints a
269+
port-forward command for acquiring tokens from the CLI. Rerunning setup rotates the
270+
development certificate and trust anchor; redeploy the gateway afterward so it reloads
271+
the mounted CA bundle.
268272

269273
Then activate OIDC in the OpenShell Helm chart:
270274
1. Uncomment `#- ci/values-keycloak.yaml` in `skaffold.yaml`
@@ -355,4 +359,4 @@ for dependencies still declared in `Chart.yaml`.
355359
| `deploy/helm/openshell/ci/values-tls-disabled.yaml` | Lint-only: TLS + auth disabled (reverse-proxy edge termination) |
356360
| `deploy/kube/manifests/envoy-gateway-openshell.yaml` | GatewayClass for Envoy Gateway (`mise run helm:gateway:apply`) |
357361
| `tasks/scripts/helm-k3s-local.sh` | k3d cluster create/delete/start/stop/status |
358-
| `tasks/scripts/keycloak-k8s-setup.sh` | Keycloak deploy + realm import |
362+
| `tasks/scripts/keycloak-k8s-setup.sh` | Keycloak deploy, realm import, and development TLS trust anchor |

‎architecture/gateway.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Supported auth modes:
215215
| Plaintext | Local development or a trusted reverse proxy boundary. |
216216
| Unauthenticated local users | Trusted Kubernetes dev or fully trusted proxy deployments only. |
217217
| Cloudflare JWT | Edge-authenticated deployments where Cloudflare Access supplies identity. |
218-
| OIDC | Bearer-token auth for users, with browser or device-code PKCE and client credentials login. JWKS validation accepts RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, and EdDSA (Ed25519) signing keys. |
218+
| OIDC | Bearer-token auth for users, with browser or device-code PKCE and client credentials login. Discovery and JWKS retrieval require HTTPS, reject redirects, and pin JWKS to the issuer origin or an explicit origin allowlist. JWKS validation accepts RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, and EdDSA (Ed25519) signing keys. |
219219

220220
The CLI persists the scopes requested during OIDC login in gateway metadata and
221221
reuses them when refreshing an access token. This preserves the intended API

‎crates/openshell-core/src/config.rs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,21 @@ pub struct TlsConfig {
319319
#[derive(Debug, Clone, Serialize, Deserialize)]
320320
#[serde(deny_unknown_fields)]
321321
pub struct OidcConfig {
322-
/// OIDC issuer URL (e.g., `http://localhost:8180/realms/openshell`).
322+
/// OIDC issuer URL (e.g., `https://idp.example.com/realms/openshell`).
323323
pub issuer: String,
324324

325+
/// Permit cleartext OIDC metadata and JWKS requests to numeric loopback
326+
/// addresses. This is a development-only escape hatch and never permits
327+
/// cleartext requests to hostnames or non-loopback addresses.
328+
#[serde(default)]
329+
pub dangerously_allow_insecure_http: bool,
330+
331+
/// Additional origins from which JWKS may be loaded. Entries must be
332+
/// origins such as `https://www.googleapis.com`, without a path, query,
333+
/// credentials, or fragment. The issuer origin is always allowed.
334+
#[serde(default)]
335+
pub jwks_allowed_origins: Vec<String>,
336+
325337
/// Expected audience (`aud`) claim. Typically the OIDC client ID.
326338
pub audience: String,
327339

0 commit comments

Comments
 (0)