Skip to content

Conversation

@Kahbazi
Copy link
Member

@Kahbazi Kahbazi commented Aug 13, 2022

No description provided.

@Kahbazi Kahbazi requested a review from Tratcher as a code owner August 13, 2022 20:16
@ghost ghost added area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer community-contribution Indicates that the PR has been added by a community member labels Aug 13, 2022
@ghost
Copy link

ghost commented Aug 13, 2022

Thanks for your PR, @Kahbazi. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

Keep these changes coming 👍🏾

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

Turns out you can mutate these results 😢

@Kahbazi
Copy link
Member Author

Kahbazi commented Aug 14, 2022

Turns out you can mutate these results 😢

I can't see how! Could you please elaborate? Is it because of the Exception object? I would argue that even in the clone method the Exception remains the same instance.

Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

Can you change AuthenticateResult.NoResult to cache?

There's a theoretical issue with caching AuthenticateResult, it can reference mutable structures like ClaimsPrincipal, AuthenticationProerties, Exception, etc.. NoResult, Skipped, and Handled might be the only cases truly safe to cache because they don't hold any mutable objects. That might be worth overlooking for extremely common scenarios. Are any of these failures especially common?

edit Oh, already discussed above 😁.

(Merged since the feedback was trivial and we're at the rc1 deadline)


internal static class AuthenticateResults
{
internal static AuthenticateResult NoSelfSigned = AuthenticateResult.Fail("Options do not allow self signed certificates.");
Copy link
Member

Choose a reason for hiding this comment

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

Style: Why define these in separate classes if they're only used in one class?

/// </summary>
public class HandleRequestResult : AuthenticateResult
{
private static readonly HandleRequestResult _noResult = new() { None = true };
Copy link
Member

Choose a reason for hiding this comment

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

Style: I think we use "NoResult" for class statics, and "_noResult" for class fields.

@Tratcher Tratcher merged commit 1b15d0e into dotnet:main Aug 15, 2022
@ghost ghost added this to the 7.0-rc1 milestone Aug 15, 2022
@Kahbazi Kahbazi deleted the kahbazi/ReuseAuthResults branch August 16, 2022 05:05
@Kahbazi
Copy link
Member Author

Kahbazi commented Aug 16, 2022

Can you change AuthenticateResult.NoResult to cache?

@Tratcher I've done that in this PR #43268

@ghost
Copy link

ghost commented Aug 16, 2022

Hi @Kahbazi. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants