diff --git a/admin/auth.go b/admin/auth.go index 447fe460..acc095f9 100644 --- a/admin/auth.go +++ b/admin/auth.go @@ -47,23 +47,19 @@ func handlerAuthCheck(h http.Handler) http.Handler { case settings.AuthSAML: samlSession, err := samlMiddleware.Session.GetSession(r) if err != nil { - log.Err(err).Msg("GetSession") http.Redirect(w, r, samlConfig.LoginURL, http.StatusFound) return } if samlSession == nil { - log.Error().Msg("No SAML session") http.Redirect(w, r, samlConfig.LogoutURL, http.StatusFound) return } jwtSessionClaims, ok := samlSession.(samlsp.JWTSessionClaims) if !ok { - log.Error().Msg("JWTSessionClaims") return } samlUser := jwtSessionClaims.Subject if samlUser == "" { - log.Error().Msg("SAML user is empty") return } // Check if user is already authenticated diff --git a/admin/main.go b/admin/main.go index 6b23b019..cdc0d5be 100644 --- a/admin/main.go +++ b/admin/main.go @@ -917,7 +917,10 @@ func osctrlAdminService() { adminMux.Handle("POST "+logoutPath, handlerAuthCheck(http.HandlerFunc(handlersAdmin.LogoutPOSTHandler))) // SAML ACS if adminConfig.Auth == settings.AuthSAML { - adminMux.Handle("GET /saml/", samlMiddleware) + adminMux.Handle("GET /saml/acs", samlMiddleware) + adminMux.Handle("POST /saml/acs", samlMiddleware) + adminMux.Handle("GET /saml/metadata", samlMiddleware) + adminMux.Handle("POST /saml/metadata", samlMiddleware) adminMux.HandleFunc("GET "+loginPath, func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, samlConfig.LoginURL, http.StatusFound) }) diff --git a/admin/saml.go b/admin/saml.go index 9ce6aa77..a94e1ad2 100644 --- a/admin/saml.go +++ b/admin/saml.go @@ -51,10 +51,37 @@ func loadSAML(file string) (JSONConfigurationSAML, error) { if err := samlRaw.Unmarshal(&cfg); err != nil { return cfg, err } + // Verify SAML configuration + if err := verifySAML(cfg); err != nil { + return cfg, err + } // No errors! return cfg, nil } +// Function to verify SAML configuration +func verifySAML(cfg JSONConfigurationSAML) error { + if cfg.CertPath == "" { + return fmt.Errorf("Missing CertPath") + } + if cfg.KeyPath == "" { + return fmt.Errorf("Missing KeyPath") + } + if cfg.MetaDataURL == "" { + return fmt.Errorf("Missing MetaDataURL") + } + if cfg.RootURL == "" { + return fmt.Errorf("Missing RootURL") + } + if cfg.LoginURL == "" { + return fmt.Errorf("Missing LoginURL") + } + if cfg.LogoutURL == "" { + return fmt.Errorf("Missing LogoutURL") + } + return nil +} + // Function to initialize variables when using SAML for authentication func keypairSAML(config JSONConfigurationSAML) (samlThings, error) { var data samlThings