mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-03 18:20:53 -06:00
[server][auth][openid] Change config structure
This commit is contained in:
@@ -54,7 +54,7 @@ func Init(cfg Config, log zerolog.Logger) error {
|
||||
return errors.New("password backend not recognized: " + cfg.Password.Backend)
|
||||
}
|
||||
|
||||
return openid.Init(cfg.OpenIDProviders, log)
|
||||
return openid.Init(cfg.OpenID, log)
|
||||
}
|
||||
|
||||
func generateRandomString(n int) string {
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
AutoCreateDomains []string `koanf:"auto_create_domains"`
|
||||
Password PasswordConfig `koanf:"password"`
|
||||
OpenIDProviders []openid.ClientConfig `koanf:"openid_providers"`
|
||||
AutoCreateDomains []string `koanf:"auto_create_domains"`
|
||||
Password PasswordConfig `koanf:"password"`
|
||||
OpenID openid.Config `koanf:"openid"`
|
||||
}
|
||||
|
||||
type PasswordConfig struct {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package openid
|
||||
|
||||
type Config struct {
|
||||
Clients []ClientConfig `koanf:"clients"`
|
||||
}
|
||||
|
||||
type ClientConfig struct {
|
||||
ID string `koanf:"id"`
|
||||
Name string `koanf:"name"`
|
||||
|
||||
@@ -23,9 +23,9 @@ type Provider struct {
|
||||
|
||||
var log zerolog.Logger
|
||||
|
||||
func Init(cfg []ClientConfig, l zerolog.Logger) error {
|
||||
func Init(cfg Config, l zerolog.Logger) error {
|
||||
log = l.With().Str("c", "auth.openid").Logger()
|
||||
for _, c := range cfg {
|
||||
for _, c := range cfg.Clients {
|
||||
clients[c.ID] = c
|
||||
if _, err := getProviderConfig(c.IssuerURL); err != nil {
|
||||
log.Warn().Err(err).Str("id", c.ID).Str("issuer_url", c.IssuerURL).Msg("Unable to get OpenID config")
|
||||
|
||||
@@ -47,12 +47,13 @@ auth:
|
||||
bind_password:
|
||||
base_dn:
|
||||
filter_template:
|
||||
# openid_providers:
|
||||
# - id: google
|
||||
# name: Google
|
||||
# issuer_url: https://accounts.google.com
|
||||
# client_id:
|
||||
# client_secret:
|
||||
# openid:
|
||||
# clients:
|
||||
# - id: google
|
||||
# name: Google
|
||||
# issuer_url: https://accounts.google.com
|
||||
# client_id:
|
||||
# client_secret:
|
||||
|
||||
|
||||
jobs:
|
||||
|
||||
Reference in New Issue
Block a user