github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/latest/reconciling/auth/auth.go (about) 1 package auth 2 3 import ( 4 "github.com/caos/orbos/internal/operator/boom/api/latest/reconciling/auth/github" 5 "github.com/caos/orbos/internal/operator/boom/api/latest/reconciling/auth/gitlab" 6 "github.com/caos/orbos/internal/operator/boom/api/latest/reconciling/auth/google" 7 "github.com/caos/orbos/internal/operator/boom/api/latest/reconciling/auth/oidc" 8 "github.com/caos/orbos/pkg/secret" 9 ) 10 11 type Auth struct { 12 //Configuration for SSO with a generic OIDC provider 13 OIDC *oidc.OIDC `json:"oidc,omitempty" yaml:"oidc,omitempty"` 14 //Configuration for SSO with Github 15 GithubConnector *github.Connector `json:"github,omitempty" yaml:"github,omitempty"` 16 //Configuration for SSO with Gitlab 17 GitlabConnector *gitlab.Connector `json:"gitlab,omitempty" yaml:"gitlab,omitempty"` 18 //Configuration for SSO with Google 19 GoogleConnector *google.Connector `json:"google,omitempty" yaml:"google,omitempty"` 20 } 21 22 func (a *Auth) IsZero() bool { 23 if (a.OIDC == nil || a.OIDC.IsZero()) && 24 (a.GithubConnector == nil || a.GithubConnector.IsZero()) && 25 (a.GitlabConnector == nil || a.GitlabConnector.IsZero()) && 26 (a.GoogleConnector == nil || a.GoogleConnector.IsZero()) { 27 return true 28 } 29 return false 30 } 31 32 func (a *Auth) InitSecrets() { 33 if a.OIDC == nil { 34 a.OIDC = &oidc.OIDC{} 35 } 36 if a.OIDC.ClientID == nil { 37 a.OIDC.ClientID = &secret.Secret{} 38 } 39 if a.OIDC.ClientSecret == nil { 40 a.OIDC.ClientSecret = &secret.Secret{} 41 } 42 if a.OIDC.ExistingClientIDSecret == nil { 43 a.OIDC.ExistingClientIDSecret = &secret.Existing{} 44 } 45 if a.OIDC.ExistingClientSecretSecret == nil { 46 a.OIDC.ExistingClientSecretSecret = &secret.Existing{} 47 } 48 49 if a.GoogleConnector == nil { 50 a.GoogleConnector = &google.Connector{} 51 } 52 if a.GoogleConnector.Config == nil { 53 a.GoogleConnector.Config = &google.Config{} 54 } 55 if a.GoogleConnector.Config.ClientID == nil { 56 a.GoogleConnector.Config.ClientID = &secret.Secret{} 57 } 58 if a.GoogleConnector.Config.ClientSecret == nil { 59 a.GoogleConnector.Config.ClientSecret = &secret.Secret{} 60 } 61 if a.GoogleConnector.Config.ServiceAccountJSON == nil { 62 a.GoogleConnector.Config.ServiceAccountJSON = &secret.Secret{} 63 } 64 if a.GoogleConnector.Config.ExistingClientIDSecret == nil { 65 a.GoogleConnector.Config.ExistingClientIDSecret = &secret.Existing{} 66 } 67 if a.GoogleConnector.Config.ExistingClientSecretSecret == nil { 68 a.GoogleConnector.Config.ExistingClientSecretSecret = &secret.Existing{} 69 } 70 if a.GoogleConnector.Config.ExistingServiceAccountJSONSecret == nil { 71 a.GoogleConnector.Config.ExistingServiceAccountJSONSecret = &secret.Existing{} 72 } 73 74 if a.GithubConnector == nil { 75 a.GithubConnector = &github.Connector{} 76 } 77 if a.GithubConnector.Config == nil { 78 a.GithubConnector.Config = &github.Config{} 79 } 80 if a.GithubConnector.Config.ClientID == nil { 81 a.GithubConnector.Config.ClientID = &secret.Secret{} 82 } 83 if a.GithubConnector.Config.ClientSecret == nil { 84 a.GithubConnector.Config.ClientSecret = &secret.Secret{} 85 } 86 if a.GithubConnector.Config.ExistingClientIDSecret == nil { 87 a.GithubConnector.Config.ExistingClientIDSecret = &secret.Existing{} 88 } 89 if a.GithubConnector.Config.ExistingClientSecretSecret == nil { 90 a.GithubConnector.Config.ExistingClientSecretSecret = &secret.Existing{} 91 } 92 93 if a.GitlabConnector == nil { 94 a.GitlabConnector = &gitlab.Connector{} 95 } 96 if a.GitlabConnector.Config == nil { 97 a.GitlabConnector.Config = &gitlab.Config{} 98 } 99 if a.GitlabConnector.Config.ClientID == nil { 100 a.GitlabConnector.Config.ClientID = &secret.Secret{} 101 } 102 if a.GitlabConnector.Config.ClientSecret == nil { 103 a.GitlabConnector.Config.ClientSecret = &secret.Secret{} 104 } 105 if a.GitlabConnector.Config.ExistingClientIDSecret == nil { 106 a.GitlabConnector.Config.ExistingClientIDSecret = &secret.Existing{} 107 } 108 if a.GitlabConnector.Config.ExistingClientSecretSecret == nil { 109 a.GitlabConnector.Config.ExistingClientSecretSecret = &secret.Existing{} 110 } 111 }