Skip to content

Commit

Permalink
oid_introspection: add SetOIDCClaims
Browse files Browse the repository at this point in the history
This method allows third-party filters to set the oidcClaimsCacheKey
which enables the use of the oidcClaimsQuery filter.

Signed-off-by: Adrien Surée <adrien.suree@zalando.de>
  • Loading branch information
Adrien Surée committed Jan 3, 2025
1 parent 44139f3 commit d517cc7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filters/auth/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,8 @@ func (f *tokenOidcFilter) Request(ctx filters.FilterContext) {
}

// saving token info for chained filter
ctx.StateBag()[oidcClaimsCacheKey] = container
// ctx.StateBag()[oidcClaimsCacheKey] = container
SetOIDCClaims(ctx, container.Claims)

// adding upstream headers
err = setHeaders(f.upstreamHeaders, ctx, container)
Expand Down
8 changes: 8 additions & 0 deletions filters/auth/oidc_introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ func NewOIDCQueryClaimsFilter() filters.Spec {
}
}

// Sets OIDC claims in the state bag.
// Intended for use with the oidcClaimsQuery filter.
func SetOIDCClaims(ctx filters.FilterContext, claims map[string]interface{}) {
ctx.StateBag()[oidcClaimsCacheKey] = tokenContainer{
Claims: claims,
}
}

func (spec *oidcIntrospectionSpec) Name() string {
switch spec.typ {
case checkOIDCQueryClaims:
Expand Down

0 comments on commit d517cc7

Please sign in to comment.