Skip to content

Commit fd9c082

Browse files
Yuan325rahulpinto19
authored andcommitted
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.
1 parent bce25ad commit fd9c082

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

internal/auth/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ type AuthService interface {
3030
AuthServiceKind() string
3131
GetName() string
3232
GetClaimsFromHeader(context.Context, http.Header) (map[string]any, error)
33+
ToConfig() AuthServiceConfig
3334
}

internal/auth/google/google.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ func (cfg Config) AuthServiceConfigKind() string {
4343
// Initialize a Google auth service
4444
func (cfg Config) Initialize() (auth.AuthService, error) {
4545
a := &AuthService{
46-
Name: cfg.Name,
47-
Kind: AuthServiceKind,
48-
ClientID: cfg.ClientID,
46+
Config: cfg,
4947
}
5048
return a, nil
5149
}
@@ -54,16 +52,18 @@ var _ auth.AuthService = AuthService{}
5452

5553
// struct used to store auth service info
5654
type AuthService struct {
57-
Name string `yaml:"name"`
58-
Kind string `yaml:"kind"`
59-
ClientID string `yaml:"clientId"`
55+
Config
6056
}
6157

6258
// Returns the auth service kind
6359
func (a AuthService) AuthServiceKind() string {
6460
return AuthServiceKind
6561
}
6662

63+
func (a AuthService) ToConfig() auth.AuthServiceConfig {
64+
return a.Config
65+
}
66+
6767
// Returns the name of the auth service
6868
func (a AuthService) GetName() string {
6969
return a.Name

0 commit comments

Comments
 (0)