In this guide you will learn how to add a login with Microsoft to your application.
/thirdparty/callback
endpoint. You can always view your redirect URL in the Hanko Cloud Console:
Organization
.Project
.Settings
, then select Identity providers
.Redirect URL
input.Microsoft Entra ID
.App registrations
in the left sidebar.New registration
.Supported account types
choose the 3rd option i.e Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
.
Redirect URI
section select Web
as the platform.Redirect URL
you obtained in the first step as the value.Register
.Essentials
section on the Overview
page (Application (client) ID
)
of your application/app registration.
You will need this when configuring your credentials with HankoCertificates & Secrets
in the sidebar.Client secrets
tab.Certificates
.New client secret
.Add
to create the secret.Value
. You will need this when
configuring your credentials with Hanko.Value
of the secret after a full page refresh. If you you forget to do so, simply
create another secret and remove the old one.upn
(UserPrincipalName)
claim. In general, the upn
domain suffix cannot be changed to an unverified domain and hence the upn
will be
prioritized over a users’ email
(see the next section). To configure
the claim:
Token configuration
section.Add optional claim
.ID
as the token type.upn
checkbox to select it as an additional optional claim.Add
.Add
.authenticationBehaviors
setting of your application to disallow unverified email domains. This should
be the default case for newly created applications, so no further steps should be required.authenticationBehaviours
as described
here.xms_edov
token claim to check if an email domain owner has been verified. We recommend implementing
this additional security measure in case the tokens do not contain a upn
(e.g. if the claim has not been configured
or the configuration has been reverted) and decisions have to be based on a users’ email
property. To do so, first open
your applications Manifest
.optionalClaims.idToken
key in the manifest. It should already contain an entry for the upn
claim you
configured in the previous step. Add an entry for the xms_edov
claim to the array (make a backup of
the manifest file, just in case):xms_edov
claim, it is listed in the Token configuration
section but it is
marked with a warning icon claiming that “[t]his claim is not supported and will not be returned in the token”.
At the time of writing this does not appear to be correct and the claim is in fact returned in the ID token.email
claim. Proceed just as described in
the previous section when you added the upn
claim.xms_edov
claim, Hanko will reject any attempt at
connecting a Microsoft account if no verified email address is provided.
Settings
and select Identity providers
.hanko-elements
web components, this URL should be the URL of the
page that embeds the web component such that errors can be processed properly by the web component.
hanko-elements
web components, this URL should be
the URL of the page that embeds the web component.
https://*.example.com
matches https://foo.example.com
and https://bar.example.com
.https://foo.example.com/*
matches URLs like https://foo.example.com/page1
and https://foo.example.com/page2
.Providers
section, select Microsoft
and use the Enable provider
toggle to enable the provider.Client ID
and Client Secret
you obtained in one of the previous section
in the remaining inputs.Save
.@teamhanko/hanko-elements
package or building a custom UI using
the @teamhanko/hanko-frontend-sdk
.
<hanko-auth>
component from our @teamhanko/hanko-elements
package in your frontend application .
On successful integration, the component will display a button for signing in with Microsoft
in the login view
of the component.error redirect URL
as well as an
allowed redirect URL
(see the previous step).