Skip to content

Commit

Permalink
Avoid extra parse of access token
Browse files Browse the repository at this point in the history
There is no need to parse the access token in the DPoPJwtBearerEvents, since the handler already parses and makes the claims available in the context.
  • Loading branch information
josephdecock committed Jan 20, 2025
1 parent dbf9357 commit d6ff003
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.Net.Http.Headers;
using static IdentityModel.OidcConstants;

Expand Down Expand Up @@ -73,16 +72,12 @@ public override async Task TokenValidated(TokenValidatedContext context)
throw new InvalidOperationException("Missing DPoP (proof token) HTTP header");
}

// TODO - Add support for introspection
var handler = new JsonWebTokenHandler();
var parsedToken = handler.ReadJsonWebToken(at);

var result = await _validator.Validate(new DPoPProofValidationContext
{
Scheme = context.Scheme.Name,
ProofToken = proofToken,
AccessToken = at,
AccessTokenClaims = context.Principal?.Claims ?? parsedToken?.Claims ?? [],
AccessTokenClaims = context.Principal?.Claims ?? [],
Method = context.HttpContext.Request.Method,
Url = context.HttpContext.Request.Scheme + "://" + context.HttpContext.Request.Host + context.HttpContext.Request.PathBase + context.HttpContext.Request.Path
});
Expand Down

0 comments on commit d6ff003

Please sign in to comment.