OpenID Connect
Configure OpenID Connect with Universal.
Last updated
Configure OpenID Connect with Universal.
Last updated
OpenID Connect requires a license.
OpenID Connect is an authentication layer on top of OAuth 2.0, an authorization framework. It is supported by many vendors and provides the ability to authenticate against systems like EntraID.
This document will outline the steps necessary to configure EntraID OpenID Connect and use it with Universal.
Within the Azure Portal, navigate to your Entra ID blade. Next, click the Enterprise Application node and then click New application.
Next, click Create your own application.
Select a name for your application and select Register an application to integrate with Microsoft Entra ID.
In the Register an application page, define a redirect URI. This will be the URL of PowerShell Universal server that EntraID will redirect the user to. This value is defined in the PowerShell Universal configuration file, appsettings.json
.
Now that the application has been created, from the Enterprise Applications page, click Single sign-on and then Go to application. This will bring you to the application registration page.
Certificates and secrets and define a new secret. This will be used with the PowerShell Universal configuration file.
Now, we'll need to capture several points of information from the application to provide to PowerShell Universal. From the application's home page, save the Application (client) and directory (tenant) ID.
Next, we need to configure group membership to provide access and claims to PowerShell Universal. Click Token configuration under the application registration. Next, clcik Add groups claims.
To provide all a user's groups to PowerShell Universal, check All groups.
For organizations that have users with many groups, you will want to limit the number of groups sent to PowerShell Universal. Sending large numbers of groups can exceed the size of the token and cause authorization failures. If you wish to limit the groups, select Groups assigned to the application.
To add groups to the application, navigate back to the Enterprise application's page and select Users and groups.
Click the Add user/group value to assign these groups to your application. When users login to PowerShell Universal, only these group claims will be provided.
To learn more about Group Overages, click here.
Read more about appsettings.json
on our Settings page.
Now that we have completed the configuration of an EntraID App Registration, we can update the appsettings.json
file with the appropriate settings. For my application, it would look something like this.
If you are using Chrome, you will also need to enable HTTPS. You will see a 500 error without HTTPS enabled.
You can use the admin console to configure OpenID Connect. We recommend this method as you will not need to restart the PowerShell Universal service after configuring OIDC.
To add a new authentication method, navigate to Security \ Authentication and add the OpenID Connect provider.
Once the provider has been added, you can click the details button to enter the settings you'll need to authenticate against your OIDC provider. After setting the OIDC options, set the provider to enabled and log out. When visiting the /admin
page, you'll be prompted for OIDC login.
You can use access tokens generated by an OIDC login for other services the user may have access to. Within your OIDC provider, like Entra ID, you can grant additional permissions to the token.
You will also have to enable access tokens within the authentication flow so that the token provides the necessary resource access.
Finally, within your PSU appsettings.json
file, you will need to ensure that SaveTokens
is enabled, the resource type includes token and the resource you wish to access is included in the Resource setting. The URL that you specify in the resource should be listed in within the provider.
The below example adds a resource for Microsoft O365.
Within your dashboard, you will now have access to an $AccessToken
and $IdToken
variable that you can use with cmdlets that require authorization.
For example, the Connect-AzureAd
cmdlet accepts an access token.
You can configure Azure Active Directory and PowerShell Universal to provide refresh tokens for requesting new tokens if the access token expires. To do so, you will need to enable offline_access in your app registration.
When configuring PowerShell Universal, you need to request the offline_access
scope and set SaveTokens to true and use the id_token response type.
Once configured, you can access the $RefreshToken
variable in your scripts and apps.
Okta supports OpenID Connect. You can configure an application to allow authentication against PowerShell Universal instances.
Within your Okta admin console, expand Applications and click Applications. Then click Create App Integration.
Select OIDC and Web Application.
Name your application and define the Sign-In redirect URL used to call your PowerShell Universal server. You will need to specify this callback URL within your PowerShell Universal configuration.
Once you've created your application, take note of your Client ID and Client Secret. You will specify these within your PowerShell Universal configuration.
Within the Sign On tab, specify the group claims filter to use for providing claims to PowerShell Universal. These claims can be used to assign roles based on group membership. The following filter returns all claims.
Once you have your Application configured, you can configure PowerShell Universal.
Once you have defined your Okta application, you can set your appsettings.json
file to use the provider for logins. Below is an example of the section required for Okta to function. Take note of the scope functionality as it is required for retrieving group membership.
In order to look up group membership for Okta, you will need to use the $UserInfo
variable that is available within roles.ps1
. This variable provides additional information about the user logging in.
The groups property will contain a list of groups the user is a member of. You can validate membership by checking whether the list contains the desired group.
Access tokens are available for users within their scripts. You can use access tokens in jobs started by users and dashboards.
For example, you could return the current user's information by using the access token provided by Okta.