Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure AD B2C self service password reset link doesn't work [closed]

Tags:

azure-ad-b2c

I have been able to properly setup sign-up/sign-in policy for a tenant I'm testing. I have set the Reset Password property to allow everybody to reset their password using their email. Currently the user signs up using their email (also their username), first name, and last name.

However, when I click on the "I forgot my password" link on the sign in page, it just redirects me back to the same page. Is there something I'm missing here?

like image 440
Riz Avatar asked Jan 06 '17 00:01

Riz


People also ask

How long does password writeback take to work?

The average time for a successful writeback of a password is under 500 ms.

Does self-service password reset require MFA?

As part of the MFA roll out for all user accounts, the IT department is also requiring all users to register for Self Service Password Reset (SSPR).

Which type of Azure Active Directory AD license allows for self service password resets in a hybrid scenarios with on premises AD write back?

Password writeback can be used to synchronize password changes in Azure AD back to your on-premises AD DS environment. Azure AD Connect provides a secure mechanism to send these password changes back to an existing on-premises directory from Azure AD.


1 Answers

There are two different mechanisms for Password Reset in Azure AD B2C:

  1. Sign-in Policy: No work required by the application, clicking on "I forgot my password" redirects the user automatically to a generic Microsoft-branded password reset page.

  2. Sign-up/sign-in Policy: This requires the application to do some extra work. Clicking on "I forgot my password" redirects the user back to the application with an error code. The application needs to detect that the error code in the request and then further redirect the user to the Azure AD B2C Password Reset Policy. The Password reset policy can be customized extensively.

Going into more details as to how to implement the second approach, here's the code that hooks up into the AuthenticationFailed notification and redirects to your own PasswordReset controller action, from the B2C Sign-up/Sign-in quickstart, Startup.Auth.cs

private Task AuthenticationFailed(AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification) {     notification.HandleResponse();      if (notification.ProtocolMessage.ErrorDescription != null && notification.ProtocolMessage.ErrorDescription.Contains("AADB2C90118"))     {         // If the user clicked the reset password link, redirect to the reset password route         notification.Response.Redirect("/Account/ResetPassword");     }     else if (notification.Exception.Message == "access_denied")     {         // If the user canceled the sign in, redirect back to the home page         notification.Response.Redirect("/");     }     else     {         notification.Response.Redirect("/Home/Error?message=" + notification.Exception.Message);     }      return Task.FromResult(0); } 

And here's the code PasswordReset controller action that redirects the user to the Password Reset B2C policy, from the same B2C Sign-up/Sign-in quickstart, Account Controller

public void ResetPassword() {     if (!Request.IsAuthenticated)     {         HttpContext.GetOwinContext().Authentication.Challenge(         new AuthenticationProperties() { RedirectUri = "/" }, Startup.PasswordResetPolicyId);     } } 

Just for sake of completeness, make sure you checkout the full guide/overview of setting up an Azure AD B2C Sign-up/Sign-in Policy

like image 159
Saca Avatar answered Sep 28 '22 20:09

Saca