mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-07 22:54:06 -05:00
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:
@@ -30,4 +30,5 @@ type AuthService interface {
|
||||
AuthServiceKind() string
|
||||
GetName() string
|
||||
GetClaimsFromHeader(context.Context, http.Header) (map[string]any, error)
|
||||
ToConfig() AuthServiceConfig
|
||||
}
|
||||
|
||||
@@ -43,9 +43,7 @@ func (cfg Config) AuthServiceConfigKind() string {
|
||||
// Initialize a Google auth service
|
||||
func (cfg Config) Initialize() (auth.AuthService, error) {
|
||||
a := &AuthService{
|
||||
Name: cfg.Name,
|
||||
Kind: AuthServiceKind,
|
||||
ClientID: cfg.ClientID,
|
||||
Config: cfg,
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
@@ -54,9 +52,7 @@ var _ auth.AuthService = AuthService{}
|
||||
|
||||
// struct used to store auth service info
|
||||
type AuthService struct {
|
||||
Name string `yaml:"name"`
|
||||
Kind string `yaml:"kind"`
|
||||
ClientID string `yaml:"clientId"`
|
||||
Config
|
||||
}
|
||||
|
||||
// Returns the auth service kind
|
||||
@@ -64,6 +60,10 @@ func (a AuthService) AuthServiceKind() string {
|
||||
return AuthServiceKind
|
||||
}
|
||||
|
||||
func (a AuthService) ToConfig() auth.AuthServiceConfig {
|
||||
return a.Config
|
||||
}
|
||||
|
||||
// Returns the name of the auth service
|
||||
func (a AuthService) GetName() string {
|
||||
return a.Name
|
||||
|
||||
Reference in New Issue
Block a user