Skip to content

Commit

Permalink
client auth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-elliott committed Sep 28, 2024
1 parent d31ada4 commit d669b0e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion handler/oauth2/strategy_jwt_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (s *JWTProfileCoreStrategy) GenerateJWT(ctx context.Context, tokenType oaut

func validateJWT(ctx context.Context, strategy jwt.Strategy, client jwt.Client, tokenString string) (token *jwt.Token, err error) {
if token, err = strategy.Decode(ctx, tokenString, jwt.WithClient(client)); err != nil {
return token, fmtValidateJWTError(token, client, err)
return nil, fmtValidateJWTError(token, client, err)
}

if err = token.Claims.Valid(); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions introspection_response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ func (f *Fosite) writeIntrospectionResponse(ctx context.Context, rw http.Respons
claims[consts.ClaimAudience] = aud
}

signer := f.Config.GetIntrospectionJWTResponseStrategy(ctx)
strategy := f.Config.GetIntrospectionJWTResponseStrategy(ctx)

if signer == nil {
f.WriteIntrospectionError(ctx, rw, errors.WithStack(ErrServerError.WithHint("Failed to generate the response.").WithDebug("The Introspection JWT could not be generated as the server is misconfigured. The Introspection Signer was not configured.")))
if strategy == nil {
f.WriteIntrospectionError(ctx, rw, errors.WithStack(ErrServerError.WithHint("Failed to generate the response.").WithDebug("The Introspection JWT could not be generated as the server is misconfigured. The Introspection jwt.Strategy was not configured.")))

return
}

if token, _, err = signer.Encode(ctx, jwt.WithClaims(claims), jwt.WithHeaders(header), jwt.WithIntrospectionClient(r.GetAccessRequester().GetClient())); err != nil {
if token, _, err = strategy.Encode(ctx, jwt.WithClaims(claims), jwt.WithHeaders(header), jwt.WithIntrospectionClient(r.GetAccessRequester().GetClient())); err != nil {
f.WriteIntrospectionError(ctx, rw, errors.WithStack(ErrServerError.WithHint("Failed to generate the response.").WithDebugf("The Introspection JWT itself could not be generated with error %+v.", err)))

return
Expand Down
2 changes: 1 addition & 1 deletion token/jarm/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func Generate(ctx context.Context, config Configurator, client Client, session a
var signer jwt.Strategy

if signer = config.GetJWTSecuredAuthorizeResponseModeStrategy(ctx); signer == nil {
return "", "", errors.New("The JARM response modes require the JWTSecuredAuthorizeResponseModeSignerProvider to return a jwt.Signer but it didn't.")
return "", "", errors.New("The JARM response modes require the JWTSecuredAuthorizeResponseModeSignerProvider to return a jwt.Strategy but it didn't.")
}

return signer.Encode(ctx, jwt.WithClaims(claims.ToMapClaims()), jwt.WithHeaders(&jwt.Headers{Extra: headers}), jwt.WithJARMClient(client))
Expand Down

0 comments on commit d669b0e

Please sign in to comment.