@@ -39,14 +39,11 @@ type Configuration struct {
3939 StoreKind model.StoreKind `mapstructure:"store_kind"`
4040
4141 // APIServerJWTAuth sets the JWT verification configuration for the conditionorc API service.
42- APIServerJWTAuth * ginjwt.AuthConfig `mapstructure:"ginjwt_auth"`
42+ APIServerJWTAuth [] ginjwt.AuthConfig `mapstructure:"ginjwt_auth"`
4343
4444 // ConditionDefinitions holds one or more condition definitions the conditionorc API, orchestrator support.
4545 ConditionDefinitions rctypes.Definitions `mapstructure:"conditions"`
4646
47- // APIOIDCOptions defines configuration to handle OIDC authn/authz for conditions API clients.
48- APIOIDCOptions APIOIDCOptions `mapstructure:"api_server_oidc"`
49-
5047 // ServerserviceOptions defines the serverservice client configuration parameters
5148 //
5249 // This parameter is required when StoreKind is set to serverservice.
@@ -66,17 +63,6 @@ type Configuration struct {
6663 Notifications notify.Configuration `mapstructure:"notifications"`
6764}
6865
69- // APIOIDCOptions defines configuration to handle OIDC authn/authz for conditions API clients.
70- type APIOIDCOptions struct {
71- EnabledOAuth bool `mapstructure:"enable_oauth"`
72- IssuerEndpoint string `mapstructure:"issuer_endpoint"`
73- AudienceEndpoint string `mapstructure:"audience_endpoint"`
74- JWKSURI string `mapstructure:"jwksuri"`
75- RolesClaim string `mapstructure:"roles_claim"`
76- UsernameClaim string `mapstructure:"username_claim"`
77- }
78-
79- // ServerserviceOptions defines configuration for the Serverservice client.
8066// https://github.com/metal-toolbox/hollow-serverservice
8167type ServerserviceOptions struct {
8268 EndpointURL * url.URL
@@ -173,41 +159,16 @@ var (
173159)
174160
175161func (a * App ) apiServerJWTAuthParams () error {
176- if ! a .v .GetBool ("api. oidc.enabled" ) {
162+ if ! a .v .GetBool ("oidc.enabled" ) {
177163 return nil
178164 }
179165
180- errOIDCAuthParams := errors .New ("conditions API OIDC Auth params not defined" )
181-
182- required := []string {
183- "audience.endpoint" ,
184- "issuer.endpoint" ,
185- "jwksuri" ,
186- "claims.roles" ,
187- "claims.username" ,
188- }
189-
190- var unset []string
191-
192- for _ , k := range required {
193- if a .v .GetString ("api.oidc." + k ) == "" {
194- unset = append (unset , "api.oidc." + k )
195- }
196- }
197-
198- if len (unset ) > 0 {
199- return errors .Wrap (errOIDCAuthParams , strings .Join (unset , "," ))
200- }
201-
202- a .Config .APIServerJWTAuth = & ginjwt.AuthConfig {
203- Enabled : true ,
204- Audience : a .v .GetString ("api.oidc.audience.endpoint" ),
205- Issuer : a .v .GetString ("api.oidc.issuer.endpoint" ),
206- JWKSURI : a .v .GetString ("api.oidc.jwksuri" ),
207- LogFields : a .v .GetStringSlice ("api.oidc.log" ),
208- RolesClaim : a .v .GetString ("api.oidc.claims.roles" ),
209- UsernameClaim : a .v .GetString ("api.oidc.claims.username" ),
166+ cfgs , err := ginjwt .GetAuthConfigsFromFlags (a .v )
167+ if err != nil {
168+ return err
210169 }
170+ a .Logger .WithField ("config.length" , len (cfgs )).Debug ("oidc configurations found" )
171+ a .Config .APIServerJWTAuth = cfgs
211172
212173 return nil
213174}
0 commit comments