Skip to content

Commit

Permalink
Turn off issuer, client id check for refresh token
Browse files Browse the repository at this point in the history
  • Loading branch information
p53 committed Dec 4, 2023
1 parent 724d689 commit 2892b28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pkg/keycloak/proxy/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ func (r *OauthProxy) oauthCallbackHandler(writer http.ResponseWriter, req *http.
r.Provider,
refreshToken,
r.Config.ClientID,
r.Config.SkipAccessTokenClientIDCheck,
r.Config.SkipAccessTokenIssuerCheck,
true,
true,
)

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/keycloak/proxy/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ func (r *OauthProxy) authenticationMiddleware() func(http.Handler) http.Handler
r.Provider,
refresh,
r.Config.ClientID,
r.Config.SkipAccessTokenClientIDCheck,
r.Config.SkipAccessTokenIssuerCheck,
true,
true,
)
if err != nil {
lLog.Error(
Expand Down
26 changes: 16 additions & 10 deletions pkg/keycloak/proxy/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,22 +637,28 @@ func verifyToken(
// we want to know if we are using valid token
// bad is that Verify method doesn't check first signatures, so
// we have to do it like this
oidcConf := &oidc3.Config{
ClientID: clientID,
SkipClientIDCheck: skipClientIDCheck,
SkipIssuerCheck: skipIssuerCheck,
SkipExpiryCheck: true,
}

verifier := provider.Verifier(oidcConf)
verifier := provider.Verifier(
&oidc3.Config{
ClientID: clientID,
SkipClientIDCheck: true,
SkipIssuerCheck: true,
SkipExpiryCheck: true,
},
)
_, err := verifier.Verify(ctx, rawToken)
if err != nil {
return nil, errors.Join(apperrors.ErrTokenSignature, err)
}

// Now doing expiration check
oidcConf.SkipExpiryCheck = false
verifier = provider.Verifier(oidcConf)
verifier = provider.Verifier(
&oidc3.Config{
ClientID: clientID,
SkipClientIDCheck: skipClientIDCheck,
SkipIssuerCheck: skipIssuerCheck,
SkipExpiryCheck: true,
},
)

oToken, err := verifier.Verify(ctx, rawToken)
if err != nil {
Expand Down

0 comments on commit 2892b28

Please sign in to comment.