Browse Source

Update the client to refresh the server configuration on SecurityTokenSignatureKeyNotFoundException

pull/1466/head
Kévin Chalet 4 years ago
parent
commit
7f85e5af9f
  1. 8
      src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs

8
src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs

@ -251,6 +251,14 @@ public static partial class OpenIddictClientHandlers
var result = await context.SecurityTokenHandler.ValidateTokenAsync(context.Token, context.TokenValidationParameters); var result = await context.SecurityTokenHandler.ValidateTokenAsync(context.Token, context.TokenValidationParameters);
if (!result.IsValid) if (!result.IsValid)
{ {
// If validation failed because of an unrecognized key identifier and a client
// registration is available, inform the configuration manager that the configuration
// MAY have be refreshed by sending a new discovery request to the authorization server.
if (context.Registration is not null && result.Exception is SecurityTokenSignatureKeyNotFoundException)
{
context.Registration.ConfigurationManager.RequestRefresh();
}
context.Logger.LogTrace(result.Exception, SR.GetResourceString(SR.ID6000), context.Token); context.Logger.LogTrace(result.Exception, SR.GetResourceString(SR.ID6000), context.Token);
context.Reject( context.Reject(

Loading…
Cancel
Save