mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-17 05:53:15 +02:00
Add optional OIDC authentication with Keycloak, Authentik, and Pocket-ID support
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/auth"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/config"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/fail2ban"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/storage"
|
||||
@@ -49,6 +50,23 @@ func main() {
|
||||
log.Fatalf("failed to initialise fail2ban connectors: %v", err)
|
||||
}
|
||||
|
||||
// Initialize OIDC authentication if enabled
|
||||
oidcConfig, err := config.GetOIDCConfigFromEnv()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to load OIDC configuration: %v", err)
|
||||
}
|
||||
if oidcConfig != nil && oidcConfig.Enabled {
|
||||
// Initialize session secret
|
||||
if err := auth.InitializeSessionSecret(oidcConfig.SessionSecret); err != nil {
|
||||
log.Fatalf("failed to initialize session secret: %v", err)
|
||||
}
|
||||
// Initialize OIDC client
|
||||
if _, err := auth.InitializeOIDC(oidcConfig); err != nil {
|
||||
log.Fatalf("failed to initialize OIDC: %v", err)
|
||||
}
|
||||
log.Println("OIDC authentication enabled")
|
||||
}
|
||||
|
||||
// Set Gin mode based on the debug flag in settings.
|
||||
if settings.Debug {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
|
||||
Reference in New Issue
Block a user