MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / NewAdminAuth

Function NewAdminAuth

cmd/cql-proxy/auth/admin.go:57–81  ·  view source on GitHub ↗

NewAdminAuth returns the admin oauth handler object.

(cfg *config.AdminAuthConfig)

Source from the content-addressed store, hash-verified

55
56// NewAdminAuth returns the admin oauth handler object.
57func NewAdminAuth(cfg *config.AdminAuthConfig) (a *AdminAuth) {
58 a = &AdminAuth{
59 cfg: cfg,
60 oauthCfg: make(map[string]*oauth2.Config),
61 }
62
63 if a.cfg != nil && a.cfg.OAuthEnabled {
64 // set default as the first one
65 for idx, clientID := range a.cfg.GithubAppID {
66 singleCfg := &oauth2.Config{
67 ClientID: clientID,
68 ClientSecret: a.cfg.GithubAppSecret[idx],
69 Endpoint: github.Endpoint,
70 }
71
72 if idx == 0 {
73 a.oauthCfg["default"] = singleCfg
74 }
75
76 a.oauthCfg[clientID] = singleCfg
77 }
78 }
79
80 return
81}
82
83// OAuthEnabled returns if oauth is enabled for administration.
84func (a *AdminAuth) OAuthEnabled() bool {

Callers 1

initAuthFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected