Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audience validation: remove exceptions #2655

Merged
merged 12 commits into from
Jun 25, 2024
Merged

Conversation

iNinja
Copy link
Contributor

@iNinja iNinja commented Jun 19, 2024

Audience validation: Remove exceptions

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • If any gains or losses in performance are possible, you've included benchmarks for your changes. More info
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Removed exceptions thrown as part of audience validation.

Description

  • Implemented new (internal momentarily) method for audience validation which replaces exception throwing with a return of the new AudienceValidationResult containing the exception information.
  • Added new delegate signature for audience validation
  • Added tests around all the previous cases.
  • Updated ambiguous references in documentation to specify the old version of ValidateAudience.

@iNinja iNinja requested a review from a team as a code owner June 19, 2024 16:57
/// <returns>A <see cref="IssuerValidationResult"/>that contains the results of validating the issuer.</returns>
/// <remarks>This delegate is not expected to throw.</remarks>
internal delegate AudienceValidationResult ValidateAudience(
IEnumerable<string> audiences,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much work would it be to change IEnumberable to IList?

Copy link
Member

@brentschmaltz brentschmaltz Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember this call will arrive from

TokenHandler.ValidateTokenAsync(
    string token,
    TokenValidationParameters validationParameters,
    CallContext callContext, 
    CancellationToken cancellationToken)
{
    // ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use IList on the new ValidateAudience method.

Copy link
Contributor

@FuPingFranco FuPingFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iNinja iNinja merged commit 3187d34 into dev Jun 25, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants