github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/v1beta1/grafana/auth/auth.go (about) 1 package auth 2 3 import ( 4 generic "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Generic" 5 github "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Github" 6 gitlab "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Gitlab" 7 google "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Google" 8 "github.com/caos/orbos/pkg/secret" 9 ) 10 11 type Auth struct { 12 //Configuration for SSO with Google 13 Google *google.Auth `json:"google,omitempty" yaml:"google,omitempty"` 14 //Configuration for SSO with Github 15 Github *github.Auth `json:"github,omitempty" yaml:"github,omitempty"` 16 //Configuration for SSO with Gitlab 17 Gitlab *gitlab.Auth `json:"gitlab,omitempty" yaml:"gitlab,omitempty"` 18 //Configuration for SSO with an generic OAuth provider 19 GenericOAuth *generic.Auth `json:"genericOAuth,omitempty" yaml:"genericOAuth,omitempty"` 20 } 21 22 func (a *Auth) IsZero() bool { 23 if (a.GenericOAuth == nil || a.GenericOAuth.IsZero()) && 24 (a.Github == nil || a.Github.IsZero()) && 25 (a.Gitlab == nil || a.Gitlab.IsZero()) && 26 (a.Google == nil || a.Google.IsZero()) { 27 return true 28 } 29 30 return false 31 } 32 33 func (a *Auth) InitSecrets() { 34 if a.GenericOAuth == nil { 35 a.GenericOAuth = &generic.Auth{} 36 } 37 if a.GenericOAuth.ClientID == nil { 38 a.GenericOAuth.ClientID = &secret.Secret{} 39 } 40 if a.GenericOAuth.ClientSecret == nil { 41 a.GenericOAuth.ClientSecret = &secret.Secret{} 42 } 43 44 if a.Google == nil { 45 a.Google = &google.Auth{} 46 } 47 if a.Google.ClientID == nil { 48 a.Google.ClientID = &secret.Secret{} 49 } 50 if a.Google.ClientSecret == nil { 51 a.Google.ClientSecret = &secret.Secret{} 52 } 53 54 if a.Github == nil { 55 a.Github = &github.Auth{} 56 } 57 if a.Github.ClientID == nil { 58 a.Github.ClientID = &secret.Secret{} 59 } 60 if a.Github.ClientSecret == nil { 61 a.Github.ClientSecret = &secret.Secret{} 62 } 63 64 if a.Gitlab == nil { 65 a.Gitlab = &gitlab.Auth{} 66 } 67 if a.Gitlab.ClientID == nil { 68 a.Gitlab.ClientID = &secret.Secret{} 69 } 70 if a.Gitlab.ClientSecret == nil { 71 a.Gitlab.ClientSecret = &secret.Secret{} 72 } 73 }