This documentation is for a release that is no longer maintained
See documentation for the latest supported version.Este contenido no está disponible en el idioma seleccionado.
Chapter 4. Authentication with Microsoft Azure
To authenticate users with Microsoft Azure:
4.1. Enabling authentication with Microsoft Azure Copiar enlaceEnlace copiado en el portapapeles!
Red Hat Developer Hub includes a Microsoft Azure authentication provider that can authenticate users by using OAuth.
Prerequisites
You have the permission to register an application in Microsoft Azure.
- You added a custom Developer Hub application configuration, and have sufficient permissions to modify it.
Procedure
To allow Developer Hub to authenticate with Microsoft Azure, create an OAuth application in Microsoft Azure.
In the Azure portal go to App registrations, create a New registration with the configuration:
- Name
- The application name in Azure, such as <My Developer Hub>.
On the Home > App registrations > <My Developer Hub> > Manage > Authentication page, Add a platform, with the following configuration:
- Redirect URI
-
Enter the backend authentication URI set in Developer Hub:
https://<my_developer_hub_url>/api/auth/microsoft/handler/frame - Front-channel logout URL
- Leave blank.
- Implicit grant and hybrid flows
- Leave all checkboxes cleared.
On the Home > App registrations > <My Developer Hub> > Manage > API permissions page, Add a Permission, then add the following Delegated permission for the Microsoft Graph API:
-
email -
offline_access -
openid -
profile -
User.Read -
Optional custom scopes for the Microsoft Graph API that you define both in this section and in the
app-config.yamlDeveloper Hub configuration file.
-
Your company might require you to grant admin consent for these permissions. Even if your company does not require admin consent, you might do so as it means users do not need to individually consent the first time they access backstage. To grant administrator consent, a directory administrator must go to the admin consent page and click Grant admin consent for COMPANY NAME.
- On the Home > App registrations > <My Developer Hub> > Manage > Certificates & Secrets page, in the Client secrets tab, create a New client secret.
Save for the next step:
- Directory (tenant) ID
- Application (client) ID
Application (client) secret
To add your Microsoft Azure credentials to Developer Hub, add the following key/value pairs to your Developer Hub secrets:
AUTH_AZURE_TENANT_ID- Enter your saved Directory (tenant) ID.
AUTH_AZURE_CLIENT_ID- Enter your saved Application (client) ID.
AUTH_AZURE_CLIENT_SECRET- Enter your saved Application (client) secret.
Set up the Microsoft Azure authentication provider in your
app-config.yamlfile:app-config.yamlfile fragmentCopy to Clipboard Copied! Toggle word wrap Toggle overflow environment: production- Mark the environment as production to hide the Guest login in the Developer Hub home page.
clientId,clientSecretandtenantId- Use the Developer Hub application information that you have created in Microsoft Azure and configured in OpenShift as secrets.
signInPage: microsoft- Enable the Microsoft Azure provider as default sign-in provider.
Optional: Consider adding following optional fields:
dangerouslyAllowSignInWithoutUserInCatalog: trueTo enable authentication without requiring to provision users in the Developer Hub software catalog.
WarningUse
dangerouslyAllowSignInWithoutUserInCatalogto explore Developer Hub features, but do not use it in production.app-config-rhdh.yamlfragment with optional field to allow authenticating users absent from the software catalogCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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 optionaldomainHintfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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 optionaladditionalScopesfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
This step is optional for environments with outgoing access restrictions, such as firewall rules. If your environment has such restrictions, ensure that your RHDH backend can access the following hosts:
-
login.microsoftonline.com: For obtaining and exchanging authorization codes and access tokens. -
graph.microsoft.com: For retrieving user profile information (as referenced in the source code). If this host is unreachable, you might see an Authentication failed, failed to fetch user profile error when attempting to log in.
= Provisioning users from Microsoft Azure to the software catalog
To authenticate users with Microsoft Azure, after Enabling authentication with Microsoft Azure, provision users from Microsoft Azure to the Developer Hub software catalog.
Prerequisites
Procedure
To enable Microsoft Azure member discovery, edit your custom Developer Hub ConfigMap, such as
app-config-rhdh, and add following lines to theapp-config.yamlcontent:app-config.yamlfragment with mandatorymicrosoftGraphOrgfieldsCopy to Clipboard Copied! Toggle word wrap Toggle overflow dangerouslyAllowSignInWithoutUserInCatalog: false- Allow authentication only for users in the Developer Hub software catalog.
target: https://graph.microsoft.com/v1.0- Defines 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,clientIdandclientSecret- Use the Developer Hub application information you created in Microsoft Azure and configured in OpenShift as secrets.
Optional: Consider adding the following optional microsoftGraphOrg.providerId fields:
authority: https://login.microsoftonline.comDefines the authority used. Change the value to use a different authority, such as Azure US government. Default value:
https://login.microsoftonline.com.app-config.yamlfragment with optionalqueryModefieldcatalog: providers: microsoftGraphOrg: providerId: authority: https://login.microsoftonline.com/catalog: providers: microsoftGraphOrg: providerId: authority: https://login.microsoftonline.com/Copy to Clipboard Copied! Toggle word wrap Toggle overflow
queryMode: basic | advancedBy default, the Microsoft Graph API only provides the
basicfeature set for querying. Certain features requireadvancedquerying capabilities. See Microsoft Azure Advanced queries.app-config.yamlfragment with optionalqueryModefieldcatalog: providers: microsoftGraphOrg: providerId: queryMode: advancedcatalog: providers: microsoftGraphOrg: providerId: queryMode: advancedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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 ] or xref:userFilter[.
app-config.yamlfragment with optionaluser.expandfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
user.filterTo filter users. See Microsoft Graph API and Microsoft Graph API query filter parameters syntax. This parameter and ???TITLE??? are mutually exclusive, only one can be specified.
app-config.yamlfragment with optionaluser.filterfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
user.loadPhotos: true | falseLoad photos by default. Set to
falseto not load user photos.app-config.yamlfragment with optionaluser.loadPhotosfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
user.selectDefine the Microsoft Graph resource types to retrieve.
app-config.yamlfragment with optionaluser.selectfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
userGroupMember.filterTo use group membership to get users. To filter groups and fetch their members. This parameter and ???TITLE??? are mutually exclusive, only one can be specified.
app-config.yamlfragment with optionaluserGroupMember.filterfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
userGroupMember.searchTo use group membership to get users. To search for groups and fetch their members. This parameter and ???TITLE??? are mutually exclusive, only one can be specified.
app-config.yamlfragment with optionaluserGroupMember.searchfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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 https://docs.microsoft.com/en-us/graph/query-parameters#expand-parameter This parameter can be combined with ] instead of xref:userFilter[.
app-config.yamlfragment with optionalgroup.expandfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
group.filterTo filter groups. See Microsoft Graph API query group syntax.
app-config.yamlfragment with optionalgroup.filterfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
group.searchTo search for groups. See Microsoft Graph API query search parameter.
app-config.yamlfragment with optionalgroup.searchfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
group.selectTo define the Microsoft Graph resource types to retrieve.
app-config.yamlfragment with optionalgroup.selectfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow schedule.frequencyTo specify custom schedule frequency. Supports cron, ISO duration, and "human duration" as used in code.
app-config.yamlfragment with optionalschedule.frequencyfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow schedule.timeoutTo specify custom timeout. Supports ISO duration and "human duration" as used in code.
app-config.yamlfragment with optionalschedule.timeoutfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow schedule.initialDelayTo specify custom initial delay. Supports ISO duration and "human duration" as used in code.
app-config.yamlfragment with optionalschedule.initialDelayfieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Check the console logs to verify that the synchronization is completed.
Successful synchronization example:
backend:start: {"class":"MicrosoftGraphOrgEntityProvider$1","level":"info","message":"Read 1 msgraph users and 1 msgraph groups in 2.2 seconds. Committing...","plugin":"catalog","service":"backstage","taskId":"MicrosoftGraphOrgEntityProvider:default:refresh","taskInstanceId":"88a67ce1-c466-41a4-9760-825e16b946be","timestamp":"2024-06-26 12:23:42"} backend:start: {"class":"MicrosoftGraphOrgEntityProvider$1","level":"info","message":"Committed 1 msgraph users and 1 msgraph groups in 0.0 seconds.","plugin":"catalog","service":"backstage","taskId":"MicrosoftGraphOrgEntityProvider:default:refresh","taskInstanceId":"88a67ce1-c466-41a4-9760-825e16b946be","timestamp":"2024-06-26 12:23:42"}backend:start: {"class":"MicrosoftGraphOrgEntityProvider$1","level":"info","message":"Read 1 msgraph users and 1 msgraph groups in 2.2 seconds. Committing...","plugin":"catalog","service":"backstage","taskId":"MicrosoftGraphOrgEntityProvider:default:refresh","taskInstanceId":"88a67ce1-c466-41a4-9760-825e16b946be","timestamp":"2024-06-26 12:23:42"} backend:start: {"class":"MicrosoftGraphOrgEntityProvider$1","level":"info","message":"Committed 1 msgraph users and 1 msgraph groups in 0.0 seconds.","plugin":"catalog","service":"backstage","taskId":"MicrosoftGraphOrgEntityProvider:default:refresh","taskInstanceId":"88a67ce1-c466-41a4-9760-825e16b946be","timestamp":"2024-06-26 12:23:42"}Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log in with a Microsoft Azure account.