> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/security/enterprise-security/openid-connect.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# OpenID Connect

Configure OpenID Connect authentication in PowerShell Universal with Entra ID or Okta, including claim mapping and delegated access tokens.

{% hint style="info" %}
OpenID Connect requires a [license](https://store.devolutions.net/package#psu).
{% endhint %}

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.

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 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.

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.

### Claim Mapping

In order to provide group claims to PowerShell Universal, you will need to expose the group claims from your app registration. Click Token Configuration and then click Add groups claim.

After clicking Add groups claim, you will have the option to select which groups are provided. If you select All Groups, the groups claims will be provided to PowerShell Universal

If you select Groups assigned to the application, ensure that you check the Emit groups as role claims value. This setting requires a paid Entra ID plan.

To assign a group to your app registration, locate your app in Enterprise Applications and click User and Groups. Next, click Add User\Group and select the groups you would like assigned to your application.

Once you have the groups claim configured in Entra ID, you can then update PowerShell Universal claim mappings to the groups provided.

For each role you would like to assign to an Entra ID group, specify the Claim Type and Claim Value for that role. For example, I have a group in my environment with the ID 446832da-d4ad-4972-b0a2-eda736129928. The Claim Type for this object is <http://schemas.microsoft.com/ws/2008/06/identity/claims/groups>.

To assign this to the administrator group, I would do the following.

Users of this group would now be part of the Administrator role in PowerShell Universal.

PowerShell Universal matches claim types after the ASP.NET Core inbound claim mapping. This mapping renames some standard claim types sent by the identity provider to a long type before roles are evaluated. For example, a `roles` claim arrives as `http://schemas.microsoft.com/ws/2008/06/identity/claims/role`, so a role with the Claim Type `roles` matches no user. The Claim Type of a role must match the claim type after this mapping. To find the exact claim types to use, see [Viewing Claim Information](#viewing-claim-information).

### 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.

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](https://learn.microsoft.com/en-us/security/zero-trust/develop/configure-tokens-group-claims-app-roles#group-overages).

### Configuring Universal for Entra ID

#### Use Appsettings.json

{% hint style="info" %}
Read more about `appsettings.json` on our [Settings ](https://docs.devolutions.net/powershell-universal/config/settings.md)page.
{% endhint %}

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.

{% code collapsedlinecount="10" %}

```javascript
    "OIDC": {
      "Enabled": "true",
      "CallbackPath": "/auth/signin-oidc",
      "ClientID": "<application ID>",
      "ClientSecret": "<client secret>",
      "Resource": "",
      "Authority": "https://login.microsoftonline.com/<directory ID>",
      "ResponseType": "code",
      "SaveTokens": "false",
      "GetUserInfo": false
    },
```

{% endcode %}

{% hint style="warning" %}
If you are using Chrome, you will also need to enable HTTPS. You will see a 500 error without HTTPS enabled.
{% endhint %}

#### 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 Secure > 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.

#### OpenID Connect settings

The OpenID Connect editor in **Secure > Authentication** and the `Set-PSUAuthenticationMethod -Type OpenIDConnect` cmdlet in `authentication.ps1` provide the following settings.

| Setting (admin console)                | `Set-PSUAuthenticationMethod` parameter | `appsettings.json` key      | Description                                                                                                                                                                                                                                   |
| -------------------------------------- | --------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Callback Path                          | `-CallbackPath` (required)              | `CallbackPath`              | The path on the PowerShell Universal server that the provider redirects to after sign-in, for example `/auth/signin-oidc`.                                                                                                                    |
| Client ID                              | `-ClientId` (required)                  | `ClientID`                  | The client (application) ID registered with the provider.                                                                                                                                                                                     |
| Client Secret                          | `-ClientSecret`                         | `ClientSecret`              | The client secret. If the value is the name of a secret variable, PowerShell Universal uses the value of that secret.                                                                                                                         |
| Client Certificate                     | `-ClientCertificate`                    | `ClientCertificate`         | Path to a PFX certificate used instead of a client secret. See [Client certificate authentication](https://docs.devolutions.net/powershell-universal/security/enterprise-security/openid-connect/client-certificate-authentication.md).       |
| Client Certificate Password            | `-ClientCertificatePassword`            | `ClientCertificatePassword` | Password of the PFX certificate, or the name of a secret variable that holds it.                                                                                                                                                              |
| Resource                               | `-Resource`                             | `Resource`                  | The resource to request access to.                                                                                                                                                                                                            |
| Authority                              | `-Authority`                            | `Authority`                 | The URL of the provider, for example `https://login.microsoftonline.com/<directory ID>`.                                                                                                                                                      |
| Response Type                          | `-ResponseType`                         | `ResponseType`              | The OpenID Connect response type. The default is `code`.                                                                                                                                                                                      |
| Use Token Lifetime                     | `-UseTokenLifetime`                     | `UseTokenLifetime`          | Uses the lifetime of the provider's token as the lifetime of the PowerShell Universal session.                                                                                                                                                |
| Require MFA                            | `-RequireMfa`                           | None                        | Sends `acr_values=mfa` to the provider when the user is redirected to sign in.                                                                                                                                                                |
| Get Claims from the user info endpoint | `-GetClaimsFromUserInfoEndpoint`        | `GetUserInfo`               | Reads additional claims from the provider's user info endpoint. The user info response is also available as the `$UserInfo` variable in role policy scripts.                                                                                  |
| Scopes                                 | `-Scopes`                               | `Scope`                     | Space-separated list of scopes to request. The default is `openid profile groups`.                                                                                                                                                            |
| Correlation Cookie Same Site           | `-CorrelationCookieSameSite`            | `CorrelationCookieSameSite` | The `SameSite` mode of the correlation cookie: `None`, `Lax`, `Strict` or `Unspecified`. When empty, the default mode is used.                                                                                                                |
| Save Tokens                            | `-SaveTokens`                           | `SaveTokens`                | Saves the access, ID and refresh tokens so they are available as `$AccessToken`, `$IdToken` and `$RefreshToken`.                                                                                                                              |
| None                                   | `-LogoutUrl`                            | None                        | URL of the provider's sign-out endpoint to use when the user signs out. This parameter belongs to its own parameter set, so it cannot be combined with `-ClientId`, `-CallbackPath` and the other OpenID Connect parameters in the same call. |
| None                                   | `-Configure`                            | None                        | A script block that receives the ASP.NET Core `OpenIdConnectOptions` object to set options that are not exposed as parameters.                                                                                                                |

`-SaveTokens`, `-UseTokenLifetime` and `-GetClaimsFromUserInfoEndpoint` are Boolean parameters, for example `-SaveTokens $true`. `-RequireMfa` is a switch parameter.

When OpenID Connect is enabled in `appsettings.json` (`Authentication:OIDC:Enabled` set to `true`), PowerShell Universal recreates the OpenID Connect method from that file every time the service starts. A method that comes from `appsettings.json` is read-only and cannot be changed in the admin console or by `authentication.ps1`. The `SaveTokens` key must be `true` or `false`.

If sign-in with the provider fails, PowerShell Universal writes `OpenID Connect authentication failed.` and the provider's error to the system log and redirects the user to a failed login page.

In the OpenID Connect dialog of ***Secure*** – ***Authentication***, the help text of ***Client Certificate*** is "Path to the PFX certificate used to authenticate the OIDC client." ***Client Secret*** and ***Client Certificate Password*** are selected from the secret variables.

### 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.

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.

{% code collapsedlinecount="10" %}

```javascript
    "OIDC": {
  "Enabled": "true",
  "CallbackPath": "/auth/signin-oidc",
  "ClientID": "<clientID>",
  "ClientSecret": "<clientSecret>",
  "Resource": "https://manage.office.com/",
  "Authority": "https://login.microsoftonline.com/tenant",
  "ResponseType": "id_token token",
  "SaveTokens": "true",
  "UseTokenLifetime": true
},
```

{% endcode %}

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.

{% code collapsedlinecount="10" %}

```powershell
Connect-AzureAD
       [-AzureEnvironmentName <EnvironmentName>]
       [-TenantId <String>]
       -AadAccessToken <String>
       [-MsAccessToken <String>]
       -AccountId <String>
       [-LogLevel <LogLevel>]
       [-LogFilePath <String>]
       [-InformationAction <ActionPreference>]
       [-InformationVariable <String>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
```

{% endcode %}

### 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.

When configuring PowerShell Universal, you need to request the `offline_access` scope and set SaveTokens to true and use the id\_token response type.

{% code collapsedlinecount="10" %}

```json
"OIDC": {
    "Enabled": "true",
    "CallbackPath": "/auth/signin-oidc",
    "ClientID": "----",
    "ClientSecret": "---",
    "Resource": "https://graph.microsoft.com",
    "Authority": "https://login.microsoftonline.com/----",
    "ResponseType": "code id_token",
    "SaveTokens": "true",
    "CorrelationCookieSameSite": "",
    "UseTokenLifetime": true,
    "Scope": "openid profile groups offline_access",
    "GetUserInfo": false
},
```

{% endcode %}

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.

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: `groups` / regex `.*`.

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.

{% code collapsedlinecount="10" %}

```json
    "OIDC": {
      "Enabled": "true",
      "CallbackPath": "/authorization-code/callback",
      "ClientID": "6f006906-643a-40fe-af00-9060cea5d6ef",
      "ClientSecret": "M~.rE56.md_MOpB2I5kwj_voFuX-i891N0",
      "Resource": "",
      "Authority": "https://poshtools.okta.com",
      "ResponseType": "code",
      "SaveTokens": "true",
      "CorrelationCookieSameSite": "",
      "UseTokenLifetime": true,
      "Scope": "openid profile groups",
      "GetUserInfo": true
    },
```

{% endcode %}

### 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.

{% code collapsedlinecount="10" %}

```powershell
param($User)

$UserInfo.groups -contains 'Administrators'
```

{% endcode %}

### 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.

{% code collapsedlinecount="10" %}

```powershell
Invoke-RestMethod https://poshtools.okta.com/oauth2/v1/userinfo -Headers @{
    Authorization = "Bearer $AccessToken"
}
```

{% endcode %}

## Viewing Claim Information

To see the claim information your identity provider sends to PowerShell Universal, sign in with an account from that provider, open the user menu, and select **User Settings** (`/admin/account`). The **Claims** table lists the **Type**, **Value Type**, and **Value** of each claim. Claim types appear after the inbound claim mapping, so use the value in the **Type** column as the Claim Type of a role. The table also includes the claims PowerShell Universal adds after sign-in, such as the roles assigned to the user and the permissions of those roles.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/security/enterprise-security/openid-connect.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
