-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Combine email and username in MapIdentityApi #49981
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk much about the design, just reviewing the code changes 😃
src/Identity/Core/src/IdentityApiEndpointRouteBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); | ||
|
||
await emailSender.SendEmailAsync(resetRequest.Email, "Reset your password", | ||
$"Reset your password using the following code: {HtmlEncoder.Default.Encode(code)}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this text be configurable eventually?
I'm reminded of the "We will never ask you for this code" story we heard recently 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably. It's not configurable with Identity UI, but you can more easily override razor pages than these endpoints. And you can scaffold them out. You could parse out the code in your IEmailSender
and do whatever, but that'd obviously be very fragile.
I think in the future we might have a higher-level abstraction with methods like SendEmailConfirmationAsync
and SendPasswordResetAsync
and a TUser
parameter. The default implementation could then just resolve the IEmailSender
and use the existing strings. That's not something we need to do immediately though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like been developed on a friday evening ...
the confirmation tag was close enough, too bad for the bug with the absolute url.
But this? Couldn't you at least follow a similar approach as with the confirmation htmlMessage
.
A configurable link would've been nice so we can make it either go to our backend or frontend to get the code from the query param. Expecting an app user to copy it correctly into a form field, is completely ridiculous. Most can't even paste an image URL, they copy their website address and hope for a wonder.
This makes MapIdentityApi more like Identity UI. The main difference is we're now forcing the user's email to match their username internally therefore we expose just the
Email
in MapIdentityApi requests and responses. There are no longer anyUsername
parameters. This makes MapIdentityApi more compatible with Identity UI and simplifies threat modeling them both.The main differences from before are:
EmailAddressAttribute
even ifRequireUniqueEmail = false
.{}
) in a POST body to see 2fa details like the shared key.BearerTokenHandler
no longer supports reconfiguringExpiresUtc
like other non-cookie auth handlers. It never supported adjusting the refresh token expiration per-signin either. And it never supportedIssuedUtc
or any otherAuthenticationProperties
.Contributes to #48433