Skip to content

Commit 7445c95

Browse files
committed
feat: Enable global disabling of verifying client id against aud on jwt
1 parent 7489eb0 commit 7445c95

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ Usage of ./observatorium-api:
151151
The gRPC Server Address against which to run rate limit checks when the rate limits are specified for a given tenant. If not specified, local, non-shared rate limiting will be used. Has precedence over other rate limiter options.
152152
-middleware.rate-limiter.type string
153153
The type of rate limiter to use when not using a gRPC rate limiter. Options: 'local' (default), 'redis' (leaky bucket algorithm). (default "local")
154+
-oidc.skip-client-id-check
155+
Skip checking audience field against client ID on tokens.
154156
-probes.dial-timeout duration
155157
The timeout for establishing connections to the probes upstream. (default 30s)
156158
-probes.endpoint string

authentication/oidc.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
// OIDCAuthenticatorType represents the oidc authentication provider type.
3535
const OIDCAuthenticatorType = "oidc"
36+
const SkipClientIDCheckConfigKey = "skipClientIDCheck"
3637

3738
func init() {
3839
onboardNewProvider(OIDCAuthenticatorType, newOIDCAuthenticator)
@@ -144,7 +145,13 @@ func newOIDCAuthenticator(c map[string]interface{}, tenant string,
144145
Scopes: []string{"openid", "profile", "email", "groups"},
145146
}
146147

147-
verifier := provider.Verifier(&oidc.Config{ClientID: config.ClientID})
148+
var skipIDResult bool
149+
skipClientIDCheck := c[SkipClientIDCheckConfigKey]
150+
if skipClientIDCheckBool, ok := skipClientIDCheck.(bool); ok {
151+
skipIDResult = skipClientIDCheckBool
152+
}
153+
154+
verifier := provider.Verifier(&oidc.Config{ClientID: config.ClientID, SkipClientIDCheck: skipIDResult})
148155

149156
oidcProvider := &oidcAuthenticator{
150157
tenant: tenant,

main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type config struct {
9797
rbacConfigPath string
9898
tenantsConfigPath string
9999

100+
auth authConfig
100101
debug debugConfig
101102
server serverConfig
102103
tls tlsConfig
@@ -108,6 +109,10 @@ type config struct {
108109
internalTracing internalTracingConfig
109110
}
110111

112+
type authConfig struct {
113+
skipClientIDCheck bool
114+
}
115+
111116
type debugConfig struct {
112117
mutexProfileFraction int
113118
blockProfileRate int
@@ -360,8 +365,10 @@ func main() {
360365
tenantsCfg.Tenants[i] = nil
361366
continue
362367
}
363-
364368
t.OIDC.config = oidcConfig
369+
if cfg.auth.skipClientIDCheck {
370+
t.OIDC.config[authentication.SkipClientIDCheckConfigKey] = true
371+
}
365372
}
366373

367374
if t.MTLS != nil {
@@ -1136,6 +1143,7 @@ func parseFlags() (config, error) {
11361143
"The log filtering level. Options: 'error', 'warn', 'info', 'debug'.")
11371144
flag.StringVar(&cfg.logFormat, "log.format", logger.LogFormatLogfmt,
11381145
"The log format to use. Options: 'logfmt', 'json'.")
1146+
flag.BoolVar(&cfg.auth.skipClientIDCheck, "oidc.skip-client-id-check", false, "Skip checking audience field against client ID on tokens.")
11391147
flag.StringVar(&cfg.internalTracing.serviceName, "internal.tracing.service-name", "observatorium_api",
11401148
"The service name to report to the tracing backend.")
11411149
flag.StringVar(&cfg.internalTracing.endpoint, "internal.tracing.otlp-http-endpoint", "",

0 commit comments

Comments
 (0)