chore: embed Config into Auth (#1865)

To keep a persistent backend storage for configuration, we will have to
keep a single source of truth. This involves supporting bi-directional
conversion between Config and AuthService.


This PR make the following changes:
* Embed Config in AuthService
* Add `ToConfig()` to extract Config from AuthService.
This commit is contained in:
Yuan Teoh
2025-11-13 16:37:23 -08:00
committed by GitHub
parent 42c8dd7ddd
commit 927881ffb9
2 changed files with 7 additions and 6 deletions

View File

@@ -30,4 +30,5 @@ type AuthService interface {
AuthServiceKind() string AuthServiceKind() string
GetName() string GetName() string
GetClaimsFromHeader(context.Context, http.Header) (map[string]any, error) GetClaimsFromHeader(context.Context, http.Header) (map[string]any, error)
ToConfig() AuthServiceConfig
} }

View File

@@ -43,9 +43,7 @@ func (cfg Config) AuthServiceConfigKind() string {
// Initialize a Google auth service // Initialize a Google auth service
func (cfg Config) Initialize() (auth.AuthService, error) { func (cfg Config) Initialize() (auth.AuthService, error) {
a := &AuthService{ a := &AuthService{
Name: cfg.Name, Config: cfg,
Kind: AuthServiceKind,
ClientID: cfg.ClientID,
} }
return a, nil return a, nil
} }
@@ -54,9 +52,7 @@ var _ auth.AuthService = AuthService{}
// struct used to store auth service info // struct used to store auth service info
type AuthService struct { type AuthService struct {
Name string `yaml:"name"` Config
Kind string `yaml:"kind"`
ClientID string `yaml:"clientId"`
} }
// Returns the auth service kind // Returns the auth service kind
@@ -64,6 +60,10 @@ func (a AuthService) AuthServiceKind() string {
return AuthServiceKind return AuthServiceKind
} }
func (a AuthService) ToConfig() auth.AuthServiceConfig {
return a.Config
}
// Returns the name of the auth service // Returns the name of the auth service
func (a AuthService) GetName() string { func (a AuthService) GetName() string {
return a.Name return a.Name