Questo contenuto non è disponibile nella lingua selezionata.
Chapter 5. Enabling user authentication with Microsoft Azure, with optional steps
Authenticate users with Microsoft Azure by provisioning the users and groups from Azure to the Developer Hub software catalog, and configuring the Azure authentication provider in Red Hat Developer Hub.
Prerequisites
You have the permission to register an application in Azure.
TipAlternatively, ask your Azure administrator to prepare the required Azure application.
- You added a custom Developer Hub application configuration, and have enough permissions to change it.
Your Developer Hub backend can access the following hosts:
login.microsoftonline.com- The Microsoft Azure authorization server, which enables the authentication flow.
graph.microsoft.com- The server for retrieving organization data, including user and group data, to import into the Developer Hub catalog.
Procedure
Register your Developer Hub app in Azure, by using the Azure portal.
- Sign in to the Microsoft Entra admin center.
- 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.
Browse to Applications > App registrations, and create a New registration with the configuration:
- Name
- Enter a name to identify your application in Azure, such as <Authenticating with Developer Hub>.
- Supported account types
- Select Accounts in this organizational directory only.
- Redirect URI
- Select a platform
- Select Web.
- URL
-
Enter the backend authentication URI set in Developer Hub:
https://<my_developer_hub_domain>/api/auth/microsoft/handler/frame
On the Applications > App registrations > <Authenticating with Developer Hub> > Manage > API permissions page, Add a Permission, Microsoft Graph, select the following permissions:
- Application Permissions
GroupMember.Read.All,User.Read.AllEnter permissions that enable provisioning user and groups to the Developer Hub software catalog.
Optional: Grant admin consent for these permissions. 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 Developer Hub.
- Delegated Permissions
User.Read,email,offline_access,openid,profileEnter permissions that enable authenticating users.
Optional: Enter optional custom scopes for the Microsoft Graph API that you define both here and in your
app-config.yamlDeveloper Hub configuration file.
- On the Applications > App registrations > <Authenticating with Developer Hub> > Manage > Certificates & secrets page, in the Client secrets tab, create a New client secret.
Save the following values for the next step:
- Directory (tenant) ID
- Application (client) ID
- Application (client) Secret ID
Add your Azure credentials to Developer Hub, by adding the following key/value pairs to your Developer Hub secrets:
MICROSOFT_TENANT_ID- Enter your saved Directory (tenant) ID.
MICROSOFT_CLIENT_ID- Enter your saved Application (client) ID.
MICROSOFT_CLIENT_SECRET- Enter your saved Application (client) secret.
Enable the Microsoft Graph catalog provider plugin in your
dynamic-plugins.yamlfile. This plugin imports Azure users and groups to the Developer Hub software catalog.plugins: - package: './dynamic-plugins/dist/backstage-plugin-catalog-backend-module-msgraph-dynamic' disabled: falseEnable provisioning Azure users and groups to the Developer Hub software catalog, by adding the Microsoft Graph catalog provider section in your
app-config.yamlfile:catalog: providers: microsoftGraphOrg: providerId: target: https://graph.microsoft.com/v1.0 tenantId: ${MICROSOFT_TENANT_ID} clientId: ${MICROSOFT_CLIENT_ID} clientSecret: ${MICROSOFT_CLIENT_SECRET} schedule: frequency: hours: 1 timeout: minutes: 50 initialDelay: minutes: 50target-
Enter
https://graph.microsoft.com/v1.0to define the MSGraph API endpoint the provider is connecting to. You might change this parameter to use a different version, such as the beta endpoint. tenandId-
Enter the configured secret variable name:
${MICROSOFT_TENANT_ID}. clientId-
Enter the configured secret variable name:
${MICROSOFT_CLIENT_ID}. clientSecret-
Enter the configured secret variable name:
${MICROSOFT_CLIENT_SECRET}. schedulefrequency- Enter the schedule frequency in the cron, ISO duration, or human duration format. In a large organization, user provisioning might take a long time, therefore avoid using a low value.
timeout- Enter the schedule timeout in the ISO duration or human duration format. In a large organization, user provisioning might take a long time, therefore avoid using a low value.
initialDelay- Enter the schedule initial delay in the ISO duration or human duration format.
Optional: Add optional fields to the Microsoft authentication provider section in your
app-config.yamlfile:catalog: providers: microsoftGraphOrg: providerId: authority: https://login.microsoftonline.com/ queryMode: advanced user: expand: manager filter: accountEnabled eq true and userType eq 'member' loadPhotos: true select: ['id', 'displayName', 'description'] userGroupMember: filter: "displayName eq 'Backstage Users'" search: '"description:One" AND ("displayName:Video" OR "displayName:Drive")' group: expand: member filter: securityEnabled eq false and mailEnabled eq true and groupTypes/any(c:c+eq+'Unified') search: '"description:One" AND ("displayName:Video" OR "displayName:Drive")' select: ['id', 'displayName', 'description']authority-
Enter your Azure authority URL if it is different from the default:
https://login.microsoftonline.com. queryMode-
Enter
advancedwhen the defaultbasicquery mode is insufficient for your queries to the Microsoft Graph API. See Microsoft Azure advanced queries. userAdd this section to configure optional user query parameters.
expandEnter your expansion parameter to include the expanded resource or collection referenced by a single relationship (navigation property) in your results. A single request can expand only one relationship. See Microsoft Graph query expand parameter.
You can combine this parameter with
userGroupMember.filteroruser.filter.filterEnter your user filter. See Microsoft Graph API and Microsoft Graph API query filter parameters syntax.
This parameter and
userGroupMember.filterare mutually exclusive, specify only one.loadPhotos-
Developer Hub loads photos by default. Enter
falseto avoid loading user photos. select- Enter the Microsoft Graph resource type list to retrieve.
userGroupMemberAdd this section to use group membership to get users.
filterEnter your filter to filter groups and fetch their members.
This parameter and
user.filterare mutually exclusive, specify only one.searchEnter your search query to search for groups and fetch their members.
This parameter and
user.filterare mutually exclusive, specify only one.
groupEnter your configuration to get groups.
expandEnter your expansion parameter to include the expanded resource or collection referenced by a single relationship (navigation property) in your results. A single request can expand only one relationship. See Customize Microsoft Graph responses with query parameters.
You can combine this parameter with
user.filteroruserGroupMember.filter.filter- Enter your group filter parameter. See Microsoft Graph API query group syntax.
search- Enter your group search parameter. See Microsoft Graph API query search parameter.
select- Enter the Microsoft Graph resource type list to retrieve.
Enable Azure authentication, by adding the Microsoft authentication provider to your
app-config.yamlfile content:auth: environment: production providers: microsoft: production: clientId: ${MICROSOFT_CLIENT_ID} clientSecret: ${MICROSOFT_CLIENT_SECRET} tenantId: ${MICROSOFT_TENANT_ID} signInPage: microsoftenvironment-
Enter
productionto disable the Guest login option in the Developer Hub login page. clientId-
Enter the configured secret variable name:
${MICROSOFT_CLIENT_ID}. clientSecret-
Enter the configured secret variable name:
${MICROSOFT_CLIENT_SECRET}. tenantId-
Enter the configured secret variable name:
${MICROSOFT_TENANT_ID}. signInPage-
Enter
microsoftto set the Azure provider as your Developer Hub sign-in provider.
Optional: Add optional fields to the Microsoft authentication provider section in your
app-config.yamlfile:auth: environment: production providers: microsoft: production: clientId: ${MICROSOFT_CLIENT_ID} clientSecret: ${MICROSOFT_CLIENT_SECRET} tenantId: ${MICROSOFT_TENANT_ID} domainHint: ${MICROSOFT_TENANT_ID} additionalScopes: - Mail.Send sessionDuration: hours: 24 signIn: resolvers: - resolver: usernameMatchingUserEntityName dangerouslyAllowSignInWithoutUserInCatalog: true signInPage: microsoftdomainHint- Leave this parameter empty, or enter the tenant ID when your application registration is single-tenant.
- Leave this parameter empty when your application registration is multi-tenant.
Enter the tenant ID to reduce login friction for users with accounts in multiple tenants, by automatically filtering out accounts from other tenants.
For more information, see Home Realm Discovery.
additionalScopesEnter the list of additional scopes to add scopes for the application registration. The default and mandatory value lists following scopes:
-
openid -
offline_access -
profile -
email -
User.Read
-
sessionDuration-
Lifespan of the user session. Enter a duration in
mslibrary (such as '24h', '2 days'), ISO duration, or "human duration" format. signIn.resolversAfter successful authentication, Developer Hub resolves the user signing in to an existing user in the Developer Hub catalog. To best match users securely for your use case, consider configuring a specific resolver.
Enter the resolver list to override the default resolver:
userIdMatchingUserEntityAnnotation.The authentication provider tries each sign-in resolver in order until it succeeds, and fails if none succeed.
WarningIn production mode, configure only one resolver to make sure users are securely matched.
resolverEnter the sign-in resolver name. Available resolvers:
emailMatchingUserEntityAnnotation- Use this resolver to look up the user by matching their Microsoft email to the email entity annotation.
emailLocalPartMatchingUserEntityName- Use this resolver to look up the user by matching their Microsoft email user name to the user entity name.
emailMatchingUserEntityProfileEmail- Use this resolver to look up the user by matching their Microsoft email to the user entity profile email.
dangerouslyAllowSignInWithoutUserInCatalogEnter
trueto configure the sign-in resolver to bypass the user provisioning requirement in the Developer Hub software catalog.WarningIn production mode, do not enable
dangerouslyAllowSignInWithoutUserInCatalog.
Verification
To verify user and group provisioning, check the console logs for
MicrosoftGraphOrgEntityProviderevents.Successful synchronization example:
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" 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"To verify Azure user authentication:
- Go to the Developer Hub login page.
- Your Developer Hub sign-in page displays Sign in using Microsoft and the Guest user sign-in is disabled.
- Log in with an Azure account.