MCPcopy
hub / github.com/PatchMon/PatchMon / applyOidcSettingsUpdate

Function applyOidcSettingsUpdate

server-source-code/internal/handler/oidc.go:521–605  ·  view source on GitHub ↗
(s *models.Settings, req map[string]interface{}, enc *util.Encryption)

Source from the content-addressed store, hash-verified

519}
520
521func applyOidcSettingsUpdate(s *models.Settings, req map[string]interface{}, enc *util.Encryption) {
522 if v, ok := getReqBool(req, "oidc_enabled", "oidcEnabled"); ok {
523 s.OidcEnabled = v
524 }
525 if v, ok := getReqString(req, "oidc_issuer_url", "oidcIssuerUrl"); ok {
526 s.OidcIssuerURL = &v
527 if v == "" {
528 s.OidcIssuerURL = nil
529 }
530 }
531 if v, ok := getReqString(req, "oidc_client_id", "oidcClientId"); ok {
532 s.OidcClientID = &v
533 if v == "" {
534 s.OidcClientID = nil
535 }
536 }
537 if v, ok := getReqStringOrEmpty(req, "oidc_client_secret", "oidcClientSecret"); ok {
538 if v == "" {
539 s.OidcClientSecret = nil
540 } else if util.IsEncrypted(v) {
541 s.OidcClientSecret = &v
542 } else if enc != nil {
543 encrypted, err := enc.Encrypt(v)
544 if err == nil {
545 s.OidcClientSecret = &encrypted
546 }
547 } else {
548 s.OidcClientSecret = &v
549 }
550 }
551 if v, ok := getReqString(req, "oidc_redirect_uri", "oidcRedirectUri"); ok {
552 s.OidcRedirectURI = &v
553 if v == "" {
554 s.OidcRedirectURI = nil
555 }
556 }
557 if v, ok := getReqString(req, "oidc_scopes", "oidcScopes"); ok {
558 t := v
559 if t == "" {
560 t = "openid email profile groups"
561 }
562 s.OidcScopes = &t
563 }
564 if v, ok := getReqBool(req, "oidc_auto_create_users", "oidcAutoCreateUsers"); ok {
565 s.OidcAutoCreateUsers = v
566 }
567 if v, ok := getReqString(req, "oidc_default_role", "oidcDefaultRole"); ok {
568 t := v
569 if t == "" {
570 t = "user"
571 }
572 s.OidcDefaultRole = &t
573 }
574 if v, ok := getReqBool(req, "oidc_disable_local_auth", "oidcDisableLocalAuth"); ok {
575 s.OidcDisableLocalAuth = v
576 }
577 if v, ok := getReqString(req, "oidc_button_text", "oidcButtonText"); ok {
578 t := v

Callers 1

UpdateSettingsMethod · 0.85

Calls 5

getReqBoolFunction · 0.85
getReqStringFunction · 0.85
getReqStringOrEmptyFunction · 0.85
strOrNilFunction · 0.85
EncryptMethod · 0.80

Tested by

no test coverage detected