|
| 1 | +[id="enabling-user-authentication-with-microsoft-azure-with-mandatory-steps-only"] |
| 2 | += Enabling user authentication with {azure-brand-name} (with mandatory steps only) |
| 3 | + |
| 4 | +To authenticate users with {azure-brand-name}, configure the {azure-short} authentication provider in {product} and provision the users and groups from {azure-short} to the {product-short} software catalog. |
| 5 | + |
| 6 | +.Prerequisites |
| 7 | +* You have the permission to register an application in {azure-short}. |
| 8 | +Alternatively, you can ask your {azure-short} administrator to prepare the required {azure-short} application. |
| 9 | + |
| 10 | +* You link:{configuring-book-url}[added a custom {product-short} application configuration], and have sufficient permissions to modify it. |
| 11 | + |
| 12 | +* Your {product-short} backend can access the following hosts: |
| 13 | + |
| 14 | +`login.microsoftonline.com`:: |
| 15 | +This is the {azure-brand-name} authorization server, which enables the authentication flow. |
| 16 | + |
| 17 | +`graph.microsoft.com`:: |
| 18 | +For retrieving organization data, including user and group data, to be ingested into the {product-short} catalog. |
| 19 | + |
| 20 | +.Procedure |
| 21 | +:my-product-app-name-in-azure: <Authenticating with {product-short}> |
| 22 | +. To allow {product-short} to authenticate with {azure-short}, link:https://learn.microsoft.com/en-us/entra/identity-platform/scenario-web-app-sign-user-app-registration?tabs=aspnetcore#register-an-app-by-using-the-azure-portal[Register an app by using the {azure-short} portal]. |
| 23 | + |
| 24 | +.. Sign in to the link:https://entra.microsoft.com/[Microsoft Entra admin center]. |
| 25 | + |
| 26 | +.. Optional: If you have access to multiple tenants, use the *Settings* icon in the top menu to switch to the tenant in which you want to register the application from the *Directories + subscriptions* menu. |
| 27 | + |
| 28 | +.. Browse to *Applications > App registrations*, and create a **New registration** with the configuration: |
| 29 | + |
| 30 | +Name:: |
| 31 | +Enter a name to identify your application in {azure-short}, such as __{my-product-app-name-in-azure}__. |
| 32 | + |
| 33 | +Supported account types:: |
| 34 | +Select *Accounts in this organizational directory only*. |
| 35 | + |
| 36 | +Redirect URI:: |
| 37 | + |
| 38 | +Select a platform::: |
| 39 | +Select *Web*. |
| 40 | + |
| 41 | +URL::: |
| 42 | +Enter the backend authentication URI set in {product-short}: `pass:c,a,q[{my-product-url}/api/auth/microsoft/handler/frame]` |
| 43 | + |
| 44 | +.. On the *Applications > App registrations > __{my-product-app-name-in-azure}__ > Manage > API permissions* page, *Add a Permission*, *Microsoft Graph*, select the following permissions: |
| 45 | + |
| 46 | +Application Permissions:: |
| 47 | +`GroupMember.Read.All`::: |
| 48 | +`User.Read.All`::: |
| 49 | +Enter permissions that enable provisioning user and groups to the {product-short} software catalog. |
| 50 | ++ |
| 51 | +Optional: *Grant admin consent* for these permissions. |
| 52 | +Even if your company does not require admin consent, consider doing so as it means users do not need to individually consent the first time they access {product-short}. |
| 53 | + |
| 54 | +Delegated Permissions:: |
| 55 | +`User.Read`::: |
| 56 | +`email`::: |
| 57 | +`offline_access`::: |
| 58 | +`openid`::: |
| 59 | +`profile`::: |
| 60 | +Enter permissions that enable authenticating users. |
| 61 | ++ |
| 62 | +Optional: Enter optional custom scopes for the Microsoft Graph API that you define both in this section and in the `{my-app-config-file}` {product-short} configuration file. |
| 63 | + |
| 64 | + |
| 65 | +.. On the *Applications > App registrations > __{my-product-app-name-in-azure}__ > Manage > Certificates & secrets* page, in the *Client secrets* tab, create a *New client secret*. |
| 66 | + |
| 67 | +.. Save the following values for the next step: |
| 68 | +- **Directory (tenant) ID** |
| 69 | +- **Application (client) ID** |
| 70 | +- **Application (client) Secret ID** |
| 71 | + |
| 72 | +. To add your {azure-short} credentials to {product-short}, add the following key/value pairs to link:{configuring-dynamic-plugins-book-url}#provisioning-your-custom-configuration[your {product-short} secrets]: |
| 73 | + |
| 74 | +`AUTHENTICATION_AZURE_TENANT_ID`:: |
| 75 | +Enter your saved *Directory (tenant) ID*. |
| 76 | + |
| 77 | +`AUTHENTICATION_AZURE_CLIENT_ID`:: |
| 78 | +Enter your saved *Application (client) ID*. |
| 79 | + |
| 80 | +`AUTHENTICATION_AZURE_CLIENT_SECRET`:: |
| 81 | +Enter your saved *Application (client) secret*. |
| 82 | + |
| 83 | +. Enable the Microsoft Graph organization provisioning plugin (`backstage-plugin-catalog-backend-module-msgraph-dynamic`). |
| 84 | +This plugin ingests {azure-short} users and groups to the {product-short} software catalog. |
| 85 | ++ |
| 86 | +.`dynamic-plugins.yaml` file fragment |
| 87 | +[source,yaml] |
| 88 | +---- |
| 89 | +plugins: |
| 90 | + - package: './dynamic-plugins/dist/backstage-plugin-catalog-backend-module-msgraph-dynamic' |
| 91 | + disabled: false |
| 92 | +---- |
| 93 | ++ |
| 94 | +include::{docdir}/artifacts/snip-technology-preview.adoc[] |
| 95 | + |
| 96 | +. To provision {azure-short} users and groups to the {product-short} software catalog, add the `catalog.providers.microsoftGraphOrg` section to your custom {product-short} `{my-app-config-file}` configuration file: |
| 97 | ++ |
| 98 | +-- |
| 99 | +[id=microsoftGraphOrgProviderId] |
| 100 | +.`{my-app-config-file}` fragment with mandatory `microsoftGraphOrg` fields |
| 101 | +[source,yaml] |
| 102 | +---- |
| 103 | +catalog: |
| 104 | + providers: |
| 105 | + microsoftGraphOrg: |
| 106 | + providerId: |
| 107 | + target: https://graph.microsoft.com/v1.0 |
| 108 | + tenantId: ${AUTHENTICATION_AZURE_TENANT_ID} |
| 109 | + clientId: ${AUTHENTICATION_AZURE_CLIENT_ID} |
| 110 | + clientSecret: ${AUTHENTICATION_AZURE_CLIENT_SECRET} |
| 111 | + schedule: |
| 112 | + frequency: |
| 113 | + hours: 1 |
| 114 | + timeout: |
| 115 | + minutes: 50 |
| 116 | + initialDelay: |
| 117 | + minutes: 50 |
| 118 | +---- |
| 119 | + |
| 120 | +`target`:: |
| 121 | +Enter `\https://graph.microsoft.com/v1.0` to define the MSGraph API endpoint the provider is connecting to. |
| 122 | +You might change this parameter to use a different version, such as the link:https://learn.microsoft.com/en-us/graph/api/overview?view=graph-rest-beta#call-the-beta-endpoint[beta endpoint]. |
| 123 | + |
| 124 | +`tenandId`:: |
| 125 | +Enter the configured secret variable name: `${AUTHENTICATION_AZURE_TENANT_ID}`. |
| 126 | + |
| 127 | +`clientId`:: |
| 128 | +Enter the configured secret variable name: `${AUTHENTICATION_AZURE_CLIENT_ID}`. |
| 129 | + |
| 130 | +`clientSecret`:: |
| 131 | +Enter the configured secret variable name: `${AUTHENTICATION_AZURE_CLIENT_SECRET}`. |
| 132 | + |
| 133 | +`schedule`:: |
| 134 | + |
| 135 | +`frequency`::: |
| 136 | +Enter the schedule frequency in the cron, ISO duration, or human duration format. |
| 137 | +In a large organization, user provisioning might take a long time, therefore avoid using a low value. |
| 138 | + |
| 139 | +`timeout`::: |
| 140 | +Enter the schedule timeout in the ISO duration or human duration format. |
| 141 | +In a large organization, user provisioning might take a long time, therefore avoid using a low value. |
| 142 | + |
| 143 | +`initialDelay`::: |
| 144 | +Enter the schedule initial delay in the ISO duration or human duration format. |
| 145 | +-- |
| 146 | + |
| 147 | +. To set up the {azure-short} authentication provider, add the `auth.providers.microsoft` section to your `{my-app-config-file}` file content: |
| 148 | ++ |
| 149 | +-- |
| 150 | +.`{my-app-config-file}` file fragment with mandatory fields to enable authentication with {azure-short} |
| 151 | +[source,yaml,subs="+quotes,+attributes"] |
| 152 | +---- |
| 153 | +auth: |
| 154 | + environment: production |
| 155 | + providers: |
| 156 | + microsoft: |
| 157 | + production: |
| 158 | + clientId: ${AUTHENTICATION_AZURE_CLIENT_ID} |
| 159 | + clientSecret: ${AUTHENTICATION_AZURE_CLIENT_SECRET} |
| 160 | + tenantId: ${AUTHENTICATION_AZURE_TENANT_ID} |
| 161 | +signInPage: microsoft |
| 162 | +---- |
| 163 | + |
| 164 | +`environment`:: |
| 165 | +Enter `production` to disable the **Guest** login option in the {product-short} login page. |
| 166 | + |
| 167 | +`clientId`:: |
| 168 | +Enter the configured secret variable name: `${AUTHENTICATION_AZURE_CLIENT_ID}`. |
| 169 | + |
| 170 | +`clientSecret`:: |
| 171 | +Enter the configured secret variable name: |
| 172 | +`${AUTHENTICATION_AZURE_CLIENT_SECRET}`. |
| 173 | + |
| 174 | +`tenantId`:: |
| 175 | +Enter the configured secret variable name: `${AUTHENTICATION_AZURE_TENANT_ID}`. |
| 176 | + |
| 177 | +`signInPage`:: |
| 178 | +Enter `microsoft` to set the {azure-short} provider as your {product-short} sign-in provider. |
| 179 | +-- |
| 180 | + |
| 181 | +.Verification |
| 182 | +. To verify user and group provisioning, check the console logs for `MicrosoftGraphOrgEntityProvider` events. |
| 183 | ++ |
| 184 | +.Successful synchronization example: |
| 185 | +[source] |
| 186 | +---- |
| 187 | +2025-06-23T13:37:55.804Z catalog info Read 9 msgraph users and 3 msgraph groups in 1.5 seconds. Committing... class="MicrosoftGraphOrgEntityProvider" taskId="MicrosoftGraphOrgEntityProvider:providerId:refresh" taskInstanceId="e104a116-6481-4ceb-9bc4-0f8f9581f959" trace_id="e4c633659cffd6b1529afa55a5bfbad7" span_id="76affd0420e8baa6" trace_flags="01" |
| 188 | +
|
| 189 | +2025-06-23T13:37:55.811Z catalog info Committed 9 msgraph users and 3 msgraph groups in 0.0 seconds. class="MicrosoftGraphOrgEntityProvider" taskId="MicrosoftGraphOrgEntityProvider:providerId:refresh" taskInstanceId="e104a116-6481-4ceb-9bc4-0f8f9581f959" trace_id="e4c633659cffd6b1529afa55a5bfbad7" span_id="76affd0420e8baa6" trace_flags="01" |
| 190 | +---- |
| 191 | + |
| 192 | +. To verify {azure-short} user authentication: |
| 193 | +.. Go to the {product-short} login page. |
| 194 | +.. Your {product-short} sign-in page displays *Sign in using Microsoft* and the Guest user sign-in is disabled. |
| 195 | +.. Log in with an {azure-short} account. |
| 196 | + |
| 197 | +.Additional resources |
| 198 | +* link:{authentication-book-url}#enabling-user-authentication-with-microsoft-azure[Enabling user authentication with {azure-brand-name} (with optional steps)]. |
0 commit comments