fix(admin): populate OIDC settings in admin panel from environment variables

The get_oidc_settings() method was reading directly from the database only,
without applying environment variable overrides. Now it uses load_effective_oidc_config()
which properly applies env var overrides (OXICLOUD_OIDC_*), ensuring the admin
panel accurately reflects the runtime configuration.
This commit is contained in:
George Wu
2026-02-18 19:25:53 -08:00
parent 4168e259a5
commit e2a2026c3d
@@ -149,7 +149,6 @@ impl AdminSettingsService {
/// Get OIDC settings for display in admin UI (secrets masked). /// Get OIDC settings for display in admin UI (secrets masked).
pub async fn get_oidc_settings(&self) -> Result<OidcSettingsDto, DomainError> { pub async fn get_oidc_settings(&self) -> Result<OidcSettingsDto, DomainError> {
let db = self.settings_repo.get_by_category("oidc").await?; let db = self.settings_repo.get_by_category("oidc").await?;
let d = OidcConfig::default();
let has_secret = db let has_secret = db
.get("oidc.client_secret") .get("oidc.client_secret")
@@ -159,28 +158,19 @@ impl AdminSettingsService {
.map(|s| !s.is_empty()) .map(|s| !s.is_empty())
.unwrap_or(false); .unwrap_or(false);
// Load effective config with env var overrides applied
let effective = self.load_effective_oidc_config().await?;
Ok(OidcSettingsDto { Ok(OidcSettingsDto {
enabled: db enabled: effective.enabled,
.get("oidc.enabled") issuer_url: effective.issuer_url,
.and_then(|v| v.parse().ok()) client_id: effective.client_id,
.unwrap_or(d.enabled),
issuer_url: db.get("oidc.issuer_url").cloned().unwrap_or_default(),
client_id: db.get("oidc.client_id").cloned().unwrap_or_default(),
client_secret_set: has_secret, client_secret_set: has_secret,
scopes: db.get("oidc.scopes").cloned().unwrap_or(d.scopes), scopes: effective.scopes,
auto_provision: db auto_provision: effective.auto_provision,
.get("oidc.auto_provision") admin_groups: effective.admin_groups,
.and_then(|v| v.parse().ok()) disable_password_login: effective.disable_password_login,
.unwrap_or(d.auto_provision), provider_name: effective.provider_name,
admin_groups: db.get("oidc.admin_groups").cloned().unwrap_or_default(),
disable_password_login: db
.get("oidc.disable_password_login")
.and_then(|v| v.parse().ok())
.unwrap_or(d.disable_password_login),
provider_name: db
.get("oidc.provider_name")
.cloned()
.unwrap_or(d.provider_name),
callback_url: self.callback_url(), callback_url: self.callback_url(),
env_overrides: self.get_env_overrides(), env_overrides: self.get_env_overrides(),
}) })