OpenID Connect
Configure OpenID Connect with Universal.
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.
Configuring Azure Entra ID (Azure Active Directory)
Within the Azure Portal, navigate to your Entra ID blade. Next, click the Enterprise Application node and then click New application.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FA0xPF25QmanMt4Wa9igY%252Fimage.png%3Falt%3Dmedia%26token%3D9d092064-3a62-43ae-951d-07ee1850ed69&width=768&dpr=4&quality=100&sign=66b23021&sv=1)
Next, click Create your own application.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FckQ8abuhbtal46tyGftV%252Fimage.png%3Falt%3Dmedia%26token%3D8b1be67d-683a-4124-90b1-cb206df3f05b&width=768&dpr=4&quality=100&sign=d05c1bc1&sv=1)
Select a name for your application and select Register an application to integrate with Microsoft Entra ID.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FrWygVyM9yTROerU0K7pS%252Fimage.png%3Falt%3Dmedia%26token%3D4f6bae55-08f4-42a7-af05-e6f22b6ed556&width=768&dpr=4&quality=100&sign=67b2b8a1&sv=1)
In the Register an application page, define a redirect URI. This will be the URL of PowerShell Universal server that Entra ID 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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FHRaEVESpwdW1qCBWBjz2%252Fimage.png%3Falt%3Dmedia%26token%3Df8a1c931-5d86-4d63-8c35-9b06a6c29ab9&width=768&dpr=4&quality=100&sign=ec51dcb7&sv=1)
Certificates and secrets and define a new secret. This will be used with the PowerShell Universal configuration file.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252F7FOmyKz7EBeRkDY8rRXB%252Fimage.png%3Falt%3Dmedia%26token%3D8ff12b58-cee2-4ebc-b32c-7bd8afd02c54&width=768&dpr=4&quality=100&sign=d2f62725&sv=1)
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FIoc6UjJvHmH11KmHa9t7%252Fimage.png%3Falt%3Dmedia%26token%3Dbe450217-d2ca-4c28-9116-c915c5252d95&width=768&dpr=4&quality=100&sign=ef1f4d5&sv=1)
Groups
Next, we need to configure group membership to provide access and claims to PowerShell Universal. Click Token configuration under the application registration. Next, click Add groups claims.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FkYAtaJrMSYJZtjxJEj0K%252Fimage.png%3Falt%3Dmedia%26token%3D8020afa4-d2ed-4a26-88f6-053c22337580&width=768&dpr=4&quality=100&sign=ca04aae8&sv=1)
To provide all a user's groups to PowerShell Universal, check All groups.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FU3CPgRLrjVr8VTtLICgT%252Fimage.png%3Falt%3Dmedia%26token%3Dd4822157-c968-4ff8-8065-a02153d643b1&width=768&dpr=4&quality=100&sign=86db6c89&sv=1)
Group Overages
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FlZkFNKt60k3GhGA8scd4%252Fimage.png%3Falt%3Dmedia%26token%3D665768eb-6b32-4ac0-9691-f8c913f96136&width=768&dpr=4&quality=100&sign=ec0388af&sv=1)
To add groups to the application, navigate back to the Enterprise application's page and select Users and groups.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252FF2M7bn9q94geKkpugamk%252Fimage.png%3Falt%3Dmedia%26token%3D025867c1-7a1a-4f1a-bc5a-e867ddb96f05&width=768&dpr=4&quality=100&sign=3220171f&sv=1)
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.
Configuring Universal for Entra ID
Use Appsettings.json
Read more about appsettings.json
on our Settings page.
Now that we have completed the configuration of an AzureAD 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.
Use Authentication.ps1
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-5d139a2502cacb3dd705c19d0b2446490e5a3a78%252Fimage%2520%28462%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=490d9fab&sv=1)
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-fef31cbb87eb964736b72b7956ef1bf8f3e7c685%252Fimage%2520%2880%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=3d650cc9&sv=1)
Delegated Access Tokens
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-74b36f9bb42ccef978d68370ef629762edeade2e%252Fimage%2520%28459%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=7737d671&sv=1)
You will also have to enable access tokens within the authentication flow so that the token provides the necessary resource access.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-fbfc43c4114e6ff245333bd08edb3d81acd7310d%252Fimage%2520%28270%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=80610558&sv=1)
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.
Refresh Tokens
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-23a3677fa665b5afd304108db045b762d4b58743%252Fimage%2520%282%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=837dc99d&sv=1)
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.
Configuring Okta
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-6bcee855a028e1b3f3cb677b2b23de92a0c23059%252Fimage%2520%28489%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=c02b347f&sv=1)
Select OIDC and Web Application.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-de6e5004036a7ca02007d19deaa35090ede36dfb%252Fimage%2520%28373%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=38fddb6a&sv=1)
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-2ba1a7b00dfb7074607d829ee63a6e7e98d8e5ed%252Fimage%2520%28170%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=76c3e276&sv=1)
Once you've created your application, take note of your Client ID and Client Secret. You will specify these within your PowerShell Universal configuration.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-1744a1568b99b55918df57f18345672f90049dab%252Fimage%2520%28306%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=346533d0&sv=1)
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-cabfc0955b78cd8b01e9f68d830396dad728dbfb%252Fimage%2520%28285%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=47b8e708&sv=1)
Once you have your Application configured, you can configure PowerShell Universal.
Configurating Universal for Okta
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.
Role-Based Access
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.
Delegated Access Tokens
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.
Last updated