diff --git a/services/kanidm/default.nix b/services/kanidm/default.nix index 890782e..744ed73 100644 --- a/services/kanidm/default.nix +++ b/services/kanidm/default.nix @@ -43,12 +43,10 @@ systems.oauth2.openbao = { displayName = "OpenBao Secrets"; - # Public client for CLI support (uses PKCE instead of client secret) - public = true; - enableLocalhostRedirects = true; - # Both CLI (localhost) and Web UI callback URLs + # Web UI callback only (CLI localhost not supported with confidential clients) originUrl = "https://vault.home.2rjus.net:8200/ui/vault/auth/oidc/oidc/callback"; originLanding = "https://vault.home.2rjus.net:8200/"; + basicSecretFile = config.vault.secrets.openbao-oauth2.outputDir; preferShortUsername = true; # Allow groups scope for role binding scopeMaps.admins = [ "openid" "profile" "email" "groups" ]; @@ -86,6 +84,14 @@ group = "kanidm"; }; + # Vault secret for OpenBao OAuth2 client secret + vault.secrets.openbao-oauth2 = { + secretPath = "services/openbao/oauth2-client-secret"; + extractKey = "password"; + services = [ "kanidm" ]; + owner = "kanidm"; + group = "kanidm"; + }; # Note: Kanidm does not expose Prometheus metrics # If metrics support is added in the future, uncomment: diff --git a/terraform/vault/approle.tf b/terraform/vault/approle.tf index 15ce4db..a88dfef 100644 --- a/terraform/vault/approle.tf +++ b/terraform/vault/approle.tf @@ -106,6 +106,7 @@ locals { "secret/data/hosts/kanidm01/*", "secret/data/kanidm/*", "secret/data/services/grafana/*", + "secret/data/services/openbao/*", ] } diff --git a/terraform/vault/oidc.tf b/terraform/vault/oidc.tf index 584ee5d..30f49f4 100644 --- a/terraform/vault/oidc.tf +++ b/terraform/vault/oidc.tf @@ -1,10 +1,11 @@ # OIDC authentication backend for Kanidm integration -# Using a public client (no secret) to support CLI localhost redirects +# Web UI only - CLI localhost redirects not supported with confidential clients resource "vault_jwt_auth_backend" "oidc" { path = "oidc" type = "oidc" oidc_discovery_url = "https://auth.home.2rjus.net/oauth2/openid/openbao" oidc_client_id = "openbao" + oidc_client_secret = random_password.auto_secrets["services/openbao/oauth2-client-secret"].result default_role = "default" tune { @@ -27,7 +28,6 @@ resource "vault_jwt_auth_backend_role" "admin" { role_type = "oidc" allowed_redirect_uris = [ - "http://localhost:8250/oidc/callback", "https://vault.home.2rjus.net:8200/ui/vault/auth/oidc/oidc/callback", ] } @@ -43,7 +43,6 @@ resource "vault_jwt_auth_backend_role" "default" { role_type = "oidc" allowed_redirect_uris = [ - "http://localhost:8250/oidc/callback", "https://vault.home.2rjus.net:8200/ui/vault/auth/oidc/oidc/callback", ] } diff --git a/terraform/vault/secrets.tf b/terraform/vault/secrets.tf index 1497da3..d27de3d 100644 --- a/terraform/vault/secrets.tf +++ b/terraform/vault/secrets.tf @@ -115,6 +115,11 @@ locals { password_length = 64 } + # OpenBao OAuth2 client secret (for Kanidm OIDC) + "services/openbao/oauth2-client-secret" = { + auto_generate = true + password_length = 64 + } # NKey for nixos-exporter NATS cache sharing "shared/nixos-exporter/nkey" = {