This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
auth.go
73 lines (65 loc) · 2.02 KB
/
auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package auth
import (
generic "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Generic"
github "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Github"
gitlab "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Gitlab"
google "github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth/Google"
"github.com/caos/orbos/internal/secret"
)
type Auth struct {
//Configuration for SSO with Google
Google *google.Auth `json:"google,omitempty" yaml:"google,omitempty"`
//Configuration for SSO with Github
Github *github.Auth `json:"github,omitempty" yaml:"github,omitempty"`
//Configuration for SSO with Gitlab
Gitlab *gitlab.Auth `json:"gitlab,omitempty" yaml:"gitlab,omitempty"`
//Configuration for SSO with an generic OAuth provider
GenericOAuth *generic.Auth `json:"genericOAuth,omitempty" yaml:"genericOAuth,omitempty"`
}
func (a *Auth) IsZero() bool {
if (a.GenericOAuth == nil || a.GenericOAuth.IsZero()) &&
(a.Github == nil || a.Github.IsZero()) &&
(a.Gitlab == nil || a.Gitlab.IsZero()) &&
(a.Google == nil || a.Google.IsZero()) {
return true
}
return false
}
func (a *Auth) InitSecrets() {
if a.GenericOAuth == nil {
a.GenericOAuth = &generic.Auth{}
}
if a.GenericOAuth.ClientID == nil {
a.GenericOAuth.ClientID = &secret.Secret{}
}
if a.GenericOAuth.ClientSecret == nil {
a.GenericOAuth.ClientSecret = &secret.Secret{}
}
if a.Google == nil {
a.Google = &google.Auth{}
}
if a.Google.ClientID == nil {
a.Google.ClientID = &secret.Secret{}
}
if a.Google.ClientSecret == nil {
a.Google.ClientSecret = &secret.Secret{}
}
if a.Github == nil {
a.Github = &github.Auth{}
}
if a.Github.ClientID == nil {
a.Github.ClientID = &secret.Secret{}
}
if a.Github.ClientSecret == nil {
a.Github.ClientSecret = &secret.Secret{}
}
if a.Gitlab == nil {
a.Gitlab = &gitlab.Auth{}
}
if a.Gitlab.ClientID == nil {
a.Gitlab.ClientID = &secret.Secret{}
}
if a.Gitlab.ClientSecret == nil {
a.Gitlab.ClientSecret = &secret.Secret{}
}
}