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

Adding end to end tests and doc for the new validation #3077

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

jmprieur
Copy link
Contributor

@jmprieur jmprieur commented Jan 6, 2025

end to end tests and doc for the new validation

The goal here is to understand the public API and the developer experience.

  1. Updated the class diagrams:
  2. Added end to end tests for the ValidationAsync (and found potential issues to discuss)

ValidationParameters and their delegates

image

ValidationErrors

image

@jmprieur jmprieur requested a review from a team as a code owner January 6, 2025 18:09
// IDX10500: Signature validation failed. No security keys were provided to validate the signature.


// TODO: this message is not right. A security key was provided. but not the right one.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll see to add a better worded message for this scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you!

Assert.Contains("IDX10211", validationResult.Error.Message);
// IDX10211: Unable to validate issuer. The 'issuer' parameter is null or whitespace.

// This message needs to be updated to specifiy that it was not specified in the ValidationParameters?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can tell, this is a similar situation to the missing audience, with the exception that TokenValidationParameters does not have a RequireIssuer flag.

Based on the RFC, iss is an optional claim, and we could still default RequireIssuer to true, but to comply we should not force it to be required.

I can see to add the flag to ValidationParameters and update the issuer validation code.

We would need to decide if we want to backport this behaviour to TokenValidationParameters.

Assert.IsType<AudienceValidationError>(validationResult.Error);
Assert.Contains("IDX10206", validationResult.Error.Message);
// IDX10206: Unable to validate audience. The 'audiences' parameter is empty.
// This message needs to be updated to specifiy that it was not specified in the ValidationParameters?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can tell, we seem to have removed the parameter RequireAudience in ValidationParameters, even though the aud claim is optional, failing if it is not present.

I'll see to bring it back and check it as part of the audience validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think ValidAudience is enough, @iNinja ?
no need to have requireAudience?

@jmprieur jmprieur merged commit 6df18f5 into feature/new-validation-model Jan 7, 2025
1 check passed
iNinja pushed a commit that referenced this pull request Jan 21, 2025
* Adding end to end tests

* Update

(cherry picked from commit 6df18f5)
iNinja added a commit that referenced this pull request Jan 24, 2025
…l from the feature branch (#3100)

* Adding end to end tests and doc for the new validation (#3077)

* Adding end to end tests

* Update

(cherry picked from commit 6df18f5)

* Added new error messages for signature validation cases that were not accurately explained in the previous.

* Updated tests failing after error message changes.

---------

Co-authored-by: Jean-Marc Prieur <jmprieur@microsoft.com>
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.

4 participants