Skip to content

Commit

Permalink
Eagerly abort introspection/revocation demands that don't have a toke…
Browse files Browse the repository at this point in the history
…n attached
  • Loading branch information
kevinchalet committed Nov 12, 2024
1 parent 07e0df9 commit d7be53a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/OpenIddict.Abstractions/OpenIddictResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,12 @@ To apply post-logout redirection responses, create a class implementing 'IOpenId
<data name="ID0457" xml:space="preserve">
<value>The '{0}' parameter cannot contain null or empty values.</value>
</data>
<data name="ID0458" xml:space="preserve">
<value>A token must be specified when using introspection.</value>
</data>
<data name="ID0459" xml:space="preserve">
<value>A token must be specified when using revocation.</value>
</data>
<data name="ID2000" xml:space="preserve">
<value>The security token is missing.</value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions src/OpenIddict.Client/OpenIddictClientHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6171,6 +6171,11 @@ public ValueTask HandleAsync(ProcessIntrospectionContext context)
throw new ArgumentNullException(nameof(context));
}

if (string.IsNullOrEmpty(context.Token))
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0458));
}

if (context.Registration is null && string.IsNullOrEmpty(context.RegistrationId) &&
context.Issuer is null && string.IsNullOrEmpty(context.ProviderName) &&
context.Options.Registrations.Count is not 1)
Expand Down Expand Up @@ -6841,6 +6846,11 @@ public ValueTask HandleAsync(ProcessRevocationContext context)
throw new ArgumentNullException(nameof(context));
}

if (string.IsNullOrEmpty(context.Token))
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0459));
}

if (context.Registration is null && string.IsNullOrEmpty(context.RegistrationId) &&
context.Issuer is null && string.IsNullOrEmpty(context.ProviderName) &&
context.Options.Registrations.Count is not 1)
Expand Down

0 comments on commit d7be53a

Please sign in to comment.