update docs and config parsing

This commit is contained in:
jnfrati
2026-04-16 17:17:51 +02:00
parent 59abdc2363
commit d62f411567
3 changed files with 25 additions and 17 deletions
+6
View File
@@ -86,6 +86,9 @@ server:
issuer: "https://example.com/oauth2"
localAuthDisabled: false
signKeyRefreshEnabled: false
# MFA session settings (applies when TOTP is enabled for an account)
# mfaSessionMaxLifetime: "24h" # Max duration for an MFA session from creation
# mfaSessionIdleTimeout: "1h" # MFA session expires after this idle period
# OAuth2 redirect URIs for dashboard
dashboardRedirectURIs:
- "https://app.example.com/nb-auth"
@@ -93,6 +96,9 @@ server:
# OAuth2 redirect URIs for CLI
cliRedirectURIs:
- "http://localhost:53000/"
# OAuth2 post-logout redirect URIs for dashboard (RP-initiated logout)
# dashboardPostLogoutRedirectURIs:
# - "https://app.example.com/"
# Optional initial admin user
# owner:
# email: "admin@example.com"
+15 -5
View File
@@ -83,9 +83,9 @@ type MFAConfig struct {
}
type MFAAuthenticator struct {
ID string `yaml:"id" json:"id"`
Type string `yaml:"type" json:"type"`
Config json.RawMessage `yaml:"config" json:"config"`
ID string `yaml:"id" json:"id"`
Type string `yaml:"type" json:"type"`
Config map[string]interface{} `yaml:"config" json:"config"`
ConnectorTypes []string `yaml:"connectorTypes" json:"connectorTypes"`
}
@@ -495,8 +495,13 @@ func (c *YAMLConfig) Validate() error {
}
func buildTotpConfig(auth MFAAuthenticator) (*server.TOTPProvider, error) {
data, err := json.Marshal(auth.Config)
if err != nil {
return nil, fmt.Errorf("failed to marshal TOTP config id: %s - %w", auth.ID, err)
}
var cfg TOTPConfig
if err := json.Unmarshal(auth.Config, &cfg); err != nil {
if err := json.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("failed to parse TOTP config id: %s - %w", auth.ID, err)
}
@@ -504,8 +509,13 @@ func buildTotpConfig(auth MFAAuthenticator) (*server.TOTPProvider, error) {
}
func buildWebAuthnConfig(auth MFAAuthenticator, issuerURL string) (*server.WebAuthnProvider, error) {
data, err := json.Marshal(auth.Config)
if err != nil {
return nil, fmt.Errorf("failed to marshal WebAuthn config id: %s - %w", auth.ID, err)
}
var cfg WebAuthnConfig
if err := json.Unmarshal(auth.Config, &cfg); err != nil {
if err := json.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("failed to parse WebAuthn config id: %s - %w", auth.ID, err)
}
+4 -12
View File
@@ -2,7 +2,6 @@ package idp
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
@@ -227,20 +226,13 @@ func sanitizePostLogoutRedirectURIs(uris []string) []string {
}
func configureMFA(cfg *dex.YAMLConfig, sessionMaxLifetime, sessionIdleTimeout string) error {
totpConfig := dex.TOTPConfig{
Issuer: "NetBird",
}
rawTotpConfig, err := json.Marshal(totpConfig)
if err != nil {
return fmt.Errorf("failed to marshal TOTP config: %v", err)
}
cfg.MFA.Authenticators = []dex.MFAAuthenticator{{
ID: "default-totp",
// Has to be caps otherwise it will fail
Type: "TOTP",
Config: rawTotpConfig,
Type: "TOTP",
Config: map[string]interface{}{
"issuer": "NetBird",
},
ConnectorTypes: []string{"local"},
}}