Skip to content

Commit d31bb9b

Browse files
committed
Rework document
- Updated formattings to make the content readable - Tested and updated some steps
1 parent 71a70d3 commit d31bb9b

File tree

1 file changed

+96
-63
lines changed

1 file changed

+96
-63
lines changed
Lines changed: 96 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,133 @@
11

2-
### Background
2+
## Background
33

4-
This is applicable to GitHub Enterprise Cloud enterprises that are enabled for [enterprise managed users (EMUs) and using Azure AD/Entra OIDC authentication](https://docs.github.com/en/enterprise-cloud@latest/admin/identity-and-access-management/using-enterprise-managed-users-for-iam/configuring-oidc-for-enterprise-managed-users).
4+
This is applicable to GitHub Enterprise Cloud enterprises that are enabled for [enterprise managed users (EMUs) and using Azure AD/Entra OIDC authentication](https://docs.github.com/en/enterprise-cloud@latest/admin/identity-and-access-management/using-enterprise-managed-users-for-iam/configuring-oidc-for-enterprise-managed-users).
55

6-
[You can adjust the lifetime of a session, and how often a managed user account needs to reauthenticate with your IdP, by changing the lifetime policy property of the ID tokens issued for GitHub from your IdP. The default lifetime is one hour](https://docs.github.com/en/enterprise-cloud@latest/admin/identity-and-access-management/using-enterprise-managed-users-for-iam/configuring-oidc-for-enterprise-managed-users#about-oidc-for-enterprise-managed-users). GitHub documentation currently links [to this Microsoft article](https://learn.microsoft.com/en-us/entra/identity-platform/configure-token-lifetimes) for configuring this ID token lifetime policy, however the PowerShell steps in that Microsoft article will not allow you to assign a token lifetime policy to the GitHub Enterprise Managed User (OIDC) app based on `ServicePrincipal` `Id` rather than application object `Id`. The token lifetime policy needs to be assigned to the `ServicePrincipal` `Id` of the app because this is the local representation of this multi-tenant app in your Azure AD/Entra tenant. It does not appear that the current PowerShell cmdlets will allow you to do this for a multi-tenant app, however the [MS Graph API](https://learn.microsoft.com/en-us/graph/use-the-api) will allow you to do this.
6+
[You can adjust the lifetime of a session, and how often a managed user account needs to reauthenticate with your IdP, by changing the lifetime policy property of the ID tokens issued for GitHub from your IdP. The default lifetime is one hour](https://docs.github.com/enterprise-cloud@latest/admin/identity-and-access-management/using-enterprise-managed-users-for-iam/configuring-oidc-for-enterprise-managed-users#about-oidc-for-enterprise-managed-users). Our GitHub public documentation currently links [to this Microsoft article](https://learn.microsoft.com/en-us/entra/identity-platform/configure-token-lifetimes) for configuring this ID token lifetime policy; however, the PowerShell steps in that Microsoft article will not allow you to assign a token lifetime policy to the GitHub Enterprise Managed User (OIDC) app based on `ServicePrincipal Id` rather than application object `Id`. The token lifetime policy needs to be assigned to the `ServicePrincipal Id` of the app because this is the local representation of this multi-tenant app in your Azure AD/Entra tenant. It does not appear that the current PowerShell `cmdlets` will allow you to do this for a multi-tenant app, however the [MS Graph API](https://learn.microsoft.com/en-us/graph/use-the-api) will allow you to do this.
77

8-
### MS Graph Explorer steps for creating a `tokenLifetimePolicy` and assigning it to the GitHub Enterprise Managed User (OIDC) app in Azure AD/Entra
8+
## MS Graph Explorer steps for creating a `tokenLifetimePolicy` and assigning it to the GitHub Enterprise Managed User (OIDC) app in Azure AD/Entra
99

10-
Here is an example of the steps for creating a `tokenLifetimePolicy` in your tenant and assigning it to the `ServicePrincipal` `Id` of the GitHub Enterprise Managed User (OIDC) app using [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer). [You can have multiple tokenLifetimePolicy policies in a tenant but can assign only one `tokenLifetimePolicy` per application](https://learn.microsoft.com/en-us/graph/api/application-post-tokenlifetimepolicies?view=graph-rest-1.0&tabs=http). If you need assistance using MS Graph Explorer, these example commands, or configuring/applying a token lifetime policy in Azure AD/Entra using MS Graph, please reach out to Microsoft Support.
10+
Here is an example of the steps for creating a `tokenLifetimePolicy` in your tenant and assigning it to the `ServicePrincipal Id` of the GitHub Enterprise Managed User (OIDC) app using [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer).
1111

12-
- **Sign into MS Graph Explorer using the admin account for your Entra tenant: https://developer.microsoft.com/en-us/graph/graph-explorer.**
12+
[You can have multiple `tokenLifetimePolicy` policies in a tenant but can only assign one `tokenLifetimePolicy` per application](https://learn.microsoft.com/en-us/graph/api/application-post-tokenlifetimepolicies?view=graph-rest-1.0&tabs=http). If you need assistance using MS Graph Explorer, these example commands, or configuring/applying a token lifetime policy in Azure AD/Entra using MS Graph, please reach out to Microsoft Support.
1313

14-
- **Set the Request Header in MS Graph Explorer to a key of `content-type` and a value of `application/json`.**
14+
1. Sign in to MS Graph Explorer using the admin account for your Azure AD/Entra tenant: https://developer.microsoft.com/en-us/graph/graph-explorer
1515

16-
- **Run the query below to get the `servicePrincipal` `Id` of the GitHub OIDC app.**
16+
1. Set the **Request Header** in MS Graph Explorer to a key of `content-type` and a value of `application/json`.
1717

18-
Request Method:
18+
1. Run the query below to get the `id` of the `servicePrincipal` for the GitHub EMU OIDC app:
1919

20-
```
21-
GET
22-
```
20+
- Request Method: `GET`
2321

24-
URL:
22+
- URL:
2523

26-
```
27-
https://graph.microsoft.com/v1.0/servicePrincipals?$filter=displayName+eq+'GitHub+Enterprise+Managed+User+(OIDC)'
28-
```
24+
```text
25+
https://graph.microsoft.com/v1.0/servicePrincipals?$filter=displayName eq 'GitHub+Enterprise+Managed+User+(OIDC)'&$select=id
26+
```
2927
30-
- **You can verify that you're able to get this `servicePrincipal` object using this `Id` with the query below:**
28+
- Example Response:
3129
32-
Request Method:
30+
```json
31+
{
32+
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#servicePrincipals(id)",
33+
"value": [
34+
{
35+
"id": "abcdefgh-ijkl-1234-mnop-qrstuvwxyz56"
36+
}
37+
]
38+
}
39+
```
3340
34-
```
35-
GET
36-
```
41+
1. You can verify that you're able to get this `servicePrincipal` object using this `id` with the query below:
3742
38-
URL:
43+
- Request Method: `GET`
3944
40-
```
41-
GET https://graph.microsoft.com/v1.0/servicePrincipals/{Service Principal ID of app goes here}
42-
```
45+
- URL:
4346
44-
- **Run the command below to create a new `tokenlifetimepolicy`. In this example, the token lifetime policy is being set to 12 hours.**
47+
> Replace the `SERVICE_PRICIPAL_ID` with the `id` of the `servicePrincipal` for the GitHub EMU OIDC app (from step 3)
4548
46-
Request Method:
49+
```text
50+
https://graph.microsoft.com/v1.0/servicePrincipals/SERVICE_PRICIPAL_ID?$select=id,appDisplayName,appId,displayName,tags
51+
```
4752
48-
```
49-
POST
50-
```
53+
1. Run the command below to create a new `tokenlifetimepolicy`. In the following example, the token lifetime policy is being set to 12 hours:
5154
52-
URL:
55+
- Request Method: `POST`
5356
54-
```
55-
https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies
56-
```
57+
- URL:
5758
58-
Request Body:
59+
```text
60+
https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies
61+
```
5962
60-
```
61-
{ "definition": [ "{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"12:00:00"}}" ], "displayName": "12hour policy", "isOrganizationDefault": false }
62-
```
63+
- Request Body:
6364
64-
The policy ID will be returned in the results.
65+
```json
66+
{
67+
"definition": [
68+
"{\"TokenLifetimePolicy\":{\"Version\":1,\"AccessTokenLifetime\":\"12:00:00\"}}"
69+
],
70+
"displayName": "12-hour policy",
71+
"isOrganizationDefault": false
72+
}
73+
```
6574
66-
- **You can run the query below to list this new policy:**
75+
The policy `id` will be listed in the results.
6776
68-
Request Method:
77+
1. You can run the query below to list this new policy:
6978
70-
```
71-
GET
72-
```
79+
- Request Method: `GET`
7380
74-
```
75-
https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies/{Id of new tokeLifeTimePolicy}
76-
```
81+
- URL:
82+
> Replace the `NEW_TOKENLIFETIMEPOLICY_ID` with the `id` of the new token lifetime policy (from step 5).
7783
78-
- **Run the command below to assign this new policy to the `servicePrincipal` of the GitHub OIDC app:**
84+
```text
85+
https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies/NEW_TOKENLIFETIMEPOLICY_ID
86+
```
7987
80-
Request Method:
88+
1. Run the command below to assign this new policy to the `servicePrincipal` of the GitHub EMU OIDC app:
8189
82-
```
83-
POST
84-
```
90+
- Request Method: `POST`
8591
86-
```
87-
https://graph.microsoft.com/v1.0/servicePrincipals/{servicePrincipal ID of the app}/tokenLifetimePolicies/$ref
88-
```
92+
- URL:
8993
90-
Request body:
94+
> Replace the `SERVICE_PRICIPAL_ID` with the `id` of the `servicePrincipal` for the GitHub EMU OIDC app (from step 3)
9195
92-
```
93-
{ "@odata.id":"https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies/{Id of the tokeLifetimePolicy" }
94-
```
96+
```text
97+
https://graph.microsoft.com/v1.0/servicePrincipals/SERVICE_PRICIPAL_ID/tokenLifetimePolicies/$ref
98+
```
9599
96-
- **The query below will show the display name of the `tokenLifetimePolicy` assigned to this app based on the `servicePrincipal` of the app.**
100+
- Request body:
97101
98-
```
99-
GET https://graph.microsoft.com/v1.0/servicePrincipals/{servicePrincipal ID of the app}/tokenLifetimePolicies?$select=displayName
100-
```
102+
> Replace the `NEW_TOKENLIFETIMEPOLICY_ID` with the `id` of the new token lifetime policy from step 5.
103+
104+
```json
105+
{
106+
"@odata.id": "https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies/NEW_TOKENLIFETIMEPOLICY_ID"
107+
}
108+
```
109+
110+
1. The query below will show the display name of the `tokenLifetimePolicy` assigned to this app based on the `servicePrincipal` of the app:
111+
112+
- Request Method: `GET`
113+
114+
- URL:
115+
116+
> Replace the `SERVICE_PRICIPAL_ID` with the `servicePrincipal Id` of the GitHub EMU OIDC app (from step 3).
117+
118+
```text
119+
https://graph.microsoft.com/v1.0/servicePrincipals/SERVICE_PRICIPAL_ID/tokenLifetimePolicies?$select=displayName
120+
```
121+
122+
- Example Response:
123+
124+
```json
125+
{
126+
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.tokenLifetimePolicy)",
127+
"value": [
128+
{
129+
"displayName": "12-hour policy"
130+
}
131+
]
132+
}
133+
```

0 commit comments

Comments
 (0)