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

Fixing so that we can have multiple of same claim type #66

Merged
merged 4 commits into from
Sep 29, 2023

Conversation

einari
Copy link
Contributor

@einari einari commented Sep 28, 2023

Fixed

  • Fixing the IdentityProviderEndpoint to handle multiple claims with same type.
  • Refactoring IdentityProviderEndpoint and setup to be more testable.
  • Added specs for IdentityProviderEndpoint and setup code.

@einari einari requested a review from smithmx September 28, 2023 13:35
/// </summary>
public class ClientPrincipal
{
#pragma warning disable CA1707, CS8618
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the warnings that are being disabled as a comment?

I have no idea what CA1707 and CS8618 are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍🏻

}

response.ContentType = "application/json; charset=utf-8";
var options = new JsonSerializerOptions(_serializerOptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

You could make the JsonSerializerOptions a class variable instead of creating it each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Makes sense.

/// <param name="request"><see cref="HttpRequest"/> that holds all the request information.</param>
/// <param name="response"><see cref="HttpResponse"/> that will be written to.</param>
/// <returns>Awaitable task.</returns>
public async Task Handler(HttpRequest request, HttpResponse response)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a style preference but I like to turn more complex conditionals into predicate functions.

So instead of checking all the request headers individually, a function called something like HasValidIdentityHeaders(). Also something further down like "IsValidJsonToken".

For a more simple method with a more technical role, it's perfectly ok to keep everything inline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree to this, and also revert the test to reduce nesting

@einari einari merged commit d698e97 into main Sep 29, 2023
4 checks passed
@einari einari deleted the fix/multiple_claims branch September 29, 2023 08:39
@einari einari requested a review from smithmx September 29, 2023 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants