How to customize B2C Expired Password Message - azure-ad-b2c

I am using B2C Custom Flows. If a user tries to signon with an expired password (older than 90 days) a message "The password has expired" is displayed. How can I customize this message. I could not find this message in the list of localized string ids https://learn.microsoft.com/en-us/azure/active-directory-b2c/localization-string-ids.

A user object must be created with the passwordPolicies property set to DisablePasswordExpiration.
This is because the local-NonInteractive technical profile fails if the password for the user has expired.
Since you are creating custom flows, then you can implement your own password policy with your own localized messages, such as that in this Azure AD B2C: Force password reset after 90 days sample.

As far as I know, there is no password expiration policy for local accounts.Did you create a local account DisablePasswordExpiration without setting the passwordPolicies attribute to?
1.If the local account is created through the built-in password policy, this policy will set the passwordPolicies attribute to DisablePasswordExpiration.
2.If you create a local account through a custom policy or Azure AD Graph API, you must manually set the passwordPolicies attribute to DisablePasswordExpiration.

Related

Azure B2C multi tenant "google" users creation and tenantId claim

Currently our team is struggling with propper architecture of Azure B2C solution for our multi tenant app.
Here is what we want to achieve. We want to enable users from certain Azure AD to authenticate. This is nicely described here with restricting tenants we want to enable.
We just want to enrich this solution with google authentication. We do not want to enable all users to be able to sign up. Is there a possibility to create google federated user programatically? We basically recieve list of emails from customer company and we create accounts in tenant). As far as I know there is no possiblity to achieve this using ms graph API when I don't have issuerUserId of user.
Do we have any possible solutions for this type of scenario? Like invitation email or so? Or maybe B2C is not a propper solution in this case.
Thanks in advance
A solution would be create the allowed users in b2c as a local account in graph api with accountEnabled as false and some generated password. Since the accountEnabled is false, user will not be able to sign in or reset the password as the default set of custom policies verify that attribute.
In the federated flow in custom policy,
Let the user complete federation.
Read the account using email address received.
If a local account exists, then link the federated account (Write alternateSecurityId to the account using objectId).
If a matching local account cannot be found, block the user by showing a selfAsserted page saying you are not allowed to sign up/in to this application.
You could also have some custom boolean extension attribute set to the local account to have an extra validation and update it's value once user completes the signup.

Azure AD B2C missing email claim with local account and user id sign-in

I am setting up a new Azure AD B2C directory with standard sign-in user policy. I plan to have the user accounts created by an administrator so sign-up policy is not required. My issue is that I want to return the email address created for a user account however when I test the user flow the email address is the only claim that's missing. Is there are reason for this and a way around it?
Test user account with email address populated.
IDP settings
User flow application claims settings
Claims return when testing user flow
B2C built-in user flow mainly collects the email addresses from 2 positions of the local account.
One is otherMails (Microsoft Grpah) / Alternate email(Azure Portal).
The other is the identity whose signInType is emailAddress (Microsoft Graph).
So if your local account is signed up with "User ID" option, there is no identity whose signInType is emailAddress. And if the otherMails (Microsoft Grpah) / Alternate email is also not set, there won't be any emails claim in the token.
Please update the properties I mentioned (otherMails / Alternate email or use email address to sign up / add an identity whose signInType is emailAddress using Microsoft Graph) to make them be included in the token.

Create b2c user with authenitcation method as email for SSPR

I am looking for powershell script to create local account users in b2c along with authentication method as email for SSPR. Could some one please advise?
That is not how AAD B2C works (although AAD does). In AAD B2C, the User Flow, or User Journey (Custom Policy), dictate what and how the user will reset the password. The default payload to create a B2C user is sufficient for a user to be compatible with a journey that forces the user to validate their email for password reset.
This is because such a journey simply reads their sign in email address and enforces they verify it.
https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=http#example-2-create-a-user-with-social-and-local-account-identities

Azure AD B2C - Force user to change password on first login

I have created a built in sign in user flow for users to sign in.
I am creating users thru power shell script where i have used ForceChangePasswordNextLogin to true. I was expecting users will be shown password change page when they login for the first time, but i always get "Password Expired" error.
Could anyone provide some inputs on this ?
While creating local accounts in B2C via Graph API/powershell, the forceChangePasswordNextSignIn property must be set to false. This is documented here: https://learn.microsoft.com/en-us/azure/active-directory-b2c/manage-user-accounts-graph-api#password-profile-property. This generates a temporary password, which is marked as expired and requires the user to provide a new password. Since, in Azure AD B2C there is a different mechanism for resetting password (i.e. by using Password Reset User flows/Custom Policies), users don't get the option to reset the password and only get The password has expired. message. In B2C, administrator accounts cannot be used to reset password or set forceChangePasswordNextSignIn = true for consumer accounts.
As of now, the only possible way to require users to reset their passwords at first logon is by using custom policy: https://github.com/azure-ad-b2c/samples/tree/master/policies/force-password-reset-first-logon.

Azure AD B2C SignUp-SignIn policy with MFA turned on - Custom Login Page

I have an asp.net web application that authenticates via Azure AD B2C tenant. I have a sign-up-sign-in policy [login is using username instead of email] with MFA turned on. I have also setup Custom UI login page [unified.html] and MFA page [phonefactor.html] in a storage blob that the policy points to. I am able to authenticate the user via the custom login page and login with MFA. The issue is when I create a new user and force the user to change the password at their first login, instead of redirecting the user to the change password screen, I am getting an invalid username and password message. When I use the Sign-In policy instead of sign-up-sign-in, the redirection to change the password works for the new user. But the sign-in policy does not have the option to specify Custom UI for login page. Am I missing anything here and how can I make this work with the sign-up-sign-in policy.
Also is there any way to get the "Password" hint like the "Username" hint in the company branding ... Password hint is not available
forceChangePasswordNextLogin only works on the sign-in policy which does not support UI customization.
In order to achieve similar functionality in the unified sign-up/sign-in policy, you'll need to implement this functionality yourself.
One option to achieve similar (albeit not quite the same) functionality is by leveraging the Password Reset policy. You would be creating new users up-front and ensuring you configure their email. You then direct them straight to the Password Reset policy for their account activation. They'll receive an email with a code which once provided, will let them provide set their password.
There's already two outstanding feature asks in the Azure AD B2C Feedback Forum that you can support:
Support Force Password Reset
Fully Customizable Sign-In Page
UPDATE
For the DIY approach:
Create the users by setting up an Azure AD app for your back-end API as outlined here:
https://learn.microsoft.com/azure/active-directory-b2c/active-directory-b2c-devquickstarts-graph-dotnet
Have your back-end API call the Graph API like this app does to create the users: https://github.com/AzureADQuickStarts/B2C-GraphAPI-DotNet.git
Send the users directly to the reset password URL /authorize/ url..

Resources