第5章 Enabling user authentication with Microsoft Azure
To authenticate users with Microsoft Azure, configure the Azure authentication provider in Red Hat Developer Hub and provision the users and groups from Azure to the Developer Hub software catalog.
Prerequisites
- You have the permission to register an application in Azure. Alternatively, you can ask your Azure administrator to prepare the required Azure application.
- You added a custom Developer Hub application configuration, and have sufficient permissions to modify it.
Your Developer Hub backend can access the following hosts:
login.microsoftonline.com- This is the Microsoft Azure authorization server, which enables the authentication flow.
graph.microsoft.com- For retrieving organization data, including user and group data, to be ingested into the Developer Hub catalog.
Procedure
To allow Developer Hub to authenticate with Azure, Register an app 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 in this section and in the
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
To add your Azure credentials to Developer Hub, add the following key/value pairs to your Developer Hub secrets:
AUTHENTICATION_AZURE_TENANT_ID- Enter your saved Directory (tenant) ID.
AUTHENTICATION_AZURE_CLIENT_ID- Enter your saved Application (client) ID.
AUTHENTICATION_AZURE_CLIENT_SECRET- Enter your saved Application (client) secret.
Enable the Microsoft Graph organization provisioning plugin (
backstage-plugin-catalog-backend-module-msgraph-dynamic). This plugin ingests Azure users and groups to the Developer Hub software catalog.dynamic-plugins.yamlfile fragmentplugins: - package: './dynamic-plugins/dist/backstage-plugin-catalog-backend-module-msgraph-dynamic' disabled: false重要These features are for Technology Preview only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend using them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information on Red Hat Technology Preview features, see Technology Preview Features Scope.
To provision Azure users and groups to the Developer Hub software catalog, add the
catalog.providers.microsoftGraphOrgsection to your custom Developer Hubapp-config.yamlconfiguration file:app-config.yamlfragment with mandatorymicrosoftGraphOrgfieldscatalog: providers: microsoftGraphOrg: providerId: target: https://graph.microsoft.com/v1.0 tenantId: ${AUTHENTICATION_AZURE_TENANT_ID} clientId: ${AUTHENTICATION_AZURE_CLIENT_ID} clientSecret: ${AUTHENTICATION_AZURE_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:
${AUTHENTICATION_AZURE_TENANT_ID}. clientId-
Enter the configured secret variable name:
${AUTHENTICATION_AZURE_CLIENT_ID}. clientSecret-
Enter the configured secret variable name:
${AUTHENTICATION_AZURE_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: Consider adding the following optional
microsoftGraphOrg.providerIdfields:authorityEnter your Azure authority URL, when different from the default:
https://login.microsoftonline.com.app-config.yamlfragment with optionalqueryModefieldcatalog: providers: microsoftGraphOrg: providerId: authority: https://login.microsoftonline.com/
queryMode: basic | advancedEnter
advancedwhen the defaultbasicquery mode is not sufficient for your queries to the Microsoft Graph API. See Microsoft Azure advanced queries.app-config.yamlfragment with optionalqueryModefieldcatalog: providers: microsoftGraphOrg: providerId: queryMode: advanced
user.expandTo include the expanded resource or collection referenced by a single relationship (navigation property) in your results. Only one relationship can be expanded in a single request. See Microsoft Graph query expand parameter. This parameter can be combined with
userGroupMember.filteroruser.filter.app-config.yamlfragment with optionaluser.expandfieldcatalog: providers: microsoftGraphOrg: providerId: user: expand: manager
user.filterTo filter users. See Microsoft Graph API and Microsoft Graph API query filter parameters syntax. This parameter and
userGroupMember.filterare mutually exclusive, only one can be specified.app-config.yamlfragment with optionaluser.filterfieldcatalog: providers: microsoftGraphOrg: providerId: user: filter: accountEnabled eq true and userType eq 'member'
user.loadPhotos: true | falseDeveloper Hub loads photos by default. Enter
falseto avoid loading user photos.app-config.yamlfragment with optionaluser.loadPhotosfieldcatalog: providers: microsoftGraphOrg: providerId: user: loadPhotos: true
user.selectEnter the Microsoft Graph resource type list to retrieve.
app-config.yamlfragment with optionaluser.selectfieldcatalog: providers: microsoftGraphOrg: providerId: user: select: ['id', 'displayName', 'description']
userGroupMember.filterTo use group membership to get users. To filter groups and fetch their members. This parameter and
user.filterare mutually exclusive, only one can be specified.app-config.yamlfragment with optionaluserGroupMember.filterfieldcatalog: providers: microsoftGraphOrg: providerId: userGroupMember: filter: "displayName eq 'Backstage Users'"
userGroupMember.searchTo use group membership to get users. To search for groups and fetch their members. This parameter and
user.filterare mutually exclusive, only one can be specified.app-config.yamlfragment with optionaluserGroupMember.searchfieldcatalog: providers: microsoftGraphOrg: providerId: userGroupMember: search: '"description:One" AND ("displayName:Video" OR "displayName:Drive")'
group.expandOptional parameter to include the expanded resource or collection referenced by a single relationship (navigation property) in your results. Only one relationship can be expanded in a single request. See Customize Microsoft Graph responses with query parameters. This parameter can be combined with
userGroupMember.filterinstead ofuser.filter.app-config.yamlfragment with optionalgroup.expandfieldcatalog: providers: microsoftGraphOrg: providerId: group: expand: member
group.filterTo filter groups. See Microsoft Graph API query group syntax.
app-config.yamlfragment with optionalgroup.filterfieldcatalog: providers: microsoftGraphOrg: providerId: group: filter: securityEnabled eq false and mailEnabled eq true and groupTypes/any(c:c+eq+'Unified')
group.searchTo search for groups. See Microsoft Graph API query search parameter.
app-config.yamlfragment with optionalgroup.searchfieldcatalog: providers: microsoftGraphOrg: providerId: group: search: '"description:One" AND ("displayName:Video" OR "displayName:Drive")'
group.selectEnter the Microsoft Graph resource type list to retrieve.
app-config.yamlfragment with optionalgroup.selectfieldcatalog: providers: microsoftGraphOrg: providerId: group: select: ['id', 'displayName', 'description']
To set up the Azure authentication provider, add the
auth.providers.microsoftsection to yourapp-config.yamlfile content:app-config.yamlfile fragment with mandatory fields to enable authentication with Azureauth: environment: production providers: microsoft: production: clientId: ${AUTHENTICATION_AZURE_CLIENT_ID} clientSecret: ${AUTHENTICATION_AZURE_CLIENT_SECRET} tenantId: ${AUTHENTICATION_AZURE_TENANT_ID} signInPage: microsoftenvironment-
Enter
productionto disable the Guest login option in the Developer Hub login page. clientId-
Enter the configured secret variable name:
${AUTHENTICATION_AZURE_CLIENT_ID}. clientSecret-
Enter the configured secret variable name:
${AUTHENTICATION_AZURE_CLIENT_SECRET}. tenantId-
Enter the configured secret variable name:
${AUTHENTICATION_AZURE_TENANT_ID}. signInPage-
Enter
microsoftto set the Azure provider as your Developer Hub sign-in provider.
Optional: Consider adding following optional fields:
domainHintOptional for single-tenant applications. You can reduce login friction for users with accounts in multiple tenants by automatically filtering out accounts from other tenants. If you want to use this parameter for a single-tenant application, uncomment and enter the tenant ID. If your application registration is multi-tenant, leave this parameter blank. For more information, see Home Realm Discovery.
app-config.yamlfile fragment with optionaldomainHintfieldauth: environment: production providers: microsoft: production: domainHint: ${AUTHENTICATION_AZURE_TENANT_ID}additionalScopesOptional for additional scopes. To add scopes for the application registration, uncomment and enter the list of scopes that you want to add. The default and mandatory value lists:
'openid', 'offline_access', 'profile', 'email', 'User.Read'.app-config.yamlfile fragment with optionaladditionalScopesfieldauth: environment: production providers: microsoft: production: additionalScopes: - Mail.SendsessionDurationLifespan of the user session. Enter a duration in
mslibrary (such as '24h', '2 days'), ISO duration, or "human duration" format.app-config-rhdh.yamlfragment with optionalsessionDurationfieldauth: providers: microsoft: production: sessionDuration: hours: 24signInresolvers- After 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.
警告In production mode, only configure one resolver to ensure users are securely matched.
app-config-rhdh.yamlfragment with optional field to allow signing in users absent from the software catalogauth: environment: production providers: microsoft: production: clientId: ${AUTHENTICATION_AZURE_CLIENT_ID} clientSecret: ${AUTHENTICATION_AZURE_CLIENT_SECRET} tenantId: ${AUTHENTICATION_AZURE_TENANT_ID} signIn: resolvers: - resolver: usernameMatchingUserEntityName dangerouslyAllowSignInWithoutUserInCatalog: true signInPage: microsoftresolverEnter the sign-in resolver name. Available resolvers:
emailMatchingUserEntityAnnotation:This resolver looks up the user by matching their Microsoft email to the email entity annotation.
emailLocalPartMatchingUserEntityName:This resolver looks up the user by matching their Microsoft email user name to the user entity name.
emailMatchingUserEntityProfileEmail:- This resolver looks up the user by matching their Microsoft email to the user entity profile email.
dangerouslyAllowSignInWithoutUserInCatalog: trueConfigure the sign-in resolver to bypass the user provisioning requirement in the Developer Hub software catalog.
警告Use
dangerouslyAllowSignInWithoutUserInCatalogto explore Developer Hub features, but do not use it in production.
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.