Skip to content

Commit 5d5ab8f

Browse files
authored
Merge pull request #233466 from MicrosoftDocs/main
Publish to Live Wednesday 4AM PST, 04/05
2 parents 3a3c598 + b219f73 commit 5d5ab8f

File tree

123 files changed

+2677
-1655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2677
-1655
lines changed

.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,12 @@
884884
"branch": "main",
885885
"branch_mapping": {}
886886
},
887+
{
888+
"path_to_root": "ms-identity-python-webapp-tutorial",
889+
"url": "https://github.com/Azure-Samples/ms-identity-python-webapp",
890+
"branch": "0.5.0",
891+
"branch_mapping": {}
892+
},
887893
{
888894
"path_to_root": "ms-identity-node",
889895
"url": "https://github.com/Azure-Samples/ms-identity-node",

.openpublishing.redirection.active-directory.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"redirect_document_id": false
77
},
88
{
9-
"source_path_from_root": "/articles/active-directory/develop/configure-token-lifetimes.md",
10-
"redirect_url": "/azure/active-directory/develop/active-directory-saml-claims-customization",
9+
"source_path_from_root": "/articles/active-directory/develop/registration-config-change-token-lifetime-how-to.md",
10+
"redirect_url": "/azure/active-directory/develop/configure-token-lifetimes",
1111
"redirect_document_id": false
1212
},
1313
{

articles/active-directory-b2c/customize-ui-with-html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Azure AD B2C runs code in your customer's browser by using [Cross-Origin Resourc
3333

3434
### Custom HTML page content
3535

36-
Create an HTML page with your own branding to serve your custom page content. This page can be a static `*.html` page, or a dynamic page like .NET, Node.js, or PHP.
36+
Create an HTML page with your own branding to serve your custom page content. This page can be a static `*.html` page, or a dynamic page like .NET, Node.js, or PHP,however, Azure B2C does not support any view engines. Any server-side rendering of the dynamic page must be performed by a dedicated web application.
3737

3838
Your custom page content can contain any HTML elements, including CSS and JavaScript, but can't include insecure elements like iframes. The only required element is a div element with `id` set to `api`, such as this one `<div id="api"></div>` within your HTML page.
3939

articles/active-directory/develop/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
- name: Customize SAML claims
141141
href: active-directory-saml-claims-customization.md
142142
- name: Set an access token lifetime policy
143-
href: registration-config-change-token-lifetime-how-to.md
143+
href: configure-token-lifetimes.md
144144
- name: Directory extension attributes
145145
href: active-directory-schema-extensions.md
146146
- name: SAML app multi-instancing

articles/active-directory/develop/active-directory-configurable-token-lifetimes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ ms.service: active-directory
99
ms.subservice: develop
1010
ms.workload: identity
1111
ms.topic: conceptual
12-
ms.date: 03/07/2023
12+
ms.date: 04/04/2023
1313
ms.author: ryanwi
1414
ms.custom: aaddev, identityplatformtop40, contperf-fy21q1
15-
ms.reviewer: ludwignick, sreyanthmora, marsma
15+
ms.reviewer: ludwignick, sreyanthmora
1616
---
1717
# Configurable token lifetimes in the Microsoft identity platform (preview)
1818

@@ -74,7 +74,7 @@ A token lifetime policy is a type of policy object that contains token lifetime
7474

7575
Reducing the Access Token Lifetime property mitigates the risk of an access token or ID token being used by a malicious actor for an extended period of time. (These tokens cannot be revoked.) The trade-off is that performance is adversely affected, because the tokens have to be replaced more often.
7676

77-
For an example, see [Create a policy for web sign-in](registration-config-change-token-lifetime-how-to.md).
77+
For an example, see [Create a policy for web sign-in](configure-token-lifetimes.md).
7878

7979
Access, ID, and SAML2 token configuration are affected by the following properties and their respectively set values:
8080

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: Set lifetimes for tokens
3+
description: Learn how to set lifetimes for access tokens issued by Microsoft identity platform.
4+
services: active-directory
5+
author: rwike77
6+
manager: CelesteDG
7+
8+
ms.service: active-directory
9+
ms.subservice: develop
10+
ms.workload: identity
11+
ms.topic: how-to
12+
ms.date: 04/04/2023
13+
ms.author: ryanwi
14+
ms.custom: identityplatformtop40, contperf-fy21q2, engagement-fy23
15+
ms.reviewer: ludwignick
16+
---
17+
# Configure token lifetime policies (preview)
18+
19+
In the following steps, you'll implement a common policy scenario that imposes new rules for token lifetime. It's possible to specify the lifetime of an access, SAML, or ID token issued by the Microsoft identity platform. This can be set for all apps in your organization or for a specific service principal. They can also be set for multi-organizations (multi-tenant application).
20+
21+
For more information, see [configurable token lifetimes](active-directory-configurable-token-lifetimes.md).
22+
23+
## Get started
24+
25+
To get started, download the latest [Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/installation).
26+
27+
## Create a policy for web sign-in
28+
29+
In the following steps, you'll create a policy that requires users to authenticate less frequently in your web app. This policy sets the lifetime of the access/ID tokens for your web app.
30+
31+
```powershell
32+
Connect-MgGraph -Scopes "Policy.ReadWrite.ApplicationConfiguration"
33+
34+
# Create a token lifetime policy
35+
$params = @{
36+
Definition = @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"4:00:00"}}')
37+
DisplayName = "WebPolicyScenario"
38+
IsOrganizationDefault = $false
39+
}
40+
$tokenLifetimePolicyId=(New-MgPolicyTokenLifetimePolicy -BodyParameter $params).Id
41+
42+
# Display the policy
43+
Get-MgPolicyTokenLifetimePolicy -TokenLifetimePolicyId $tokenLifetimePolicyId
44+
45+
# Assign the token lifetime policy to an app
46+
$params = @{
47+
"@odata.id" = "https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies/$tokenLifetimePolicyId"
48+
}
49+
50+
$applicationObjectId="11111111-1111-1111-1111-111111111111"
51+
52+
New-MgApplicationTokenLifetimePolicyByRef -ApplicationId $applicationObjectId -BodyParameter $params
53+
54+
# List the token lifetime policy on the app
55+
Get-MgApplicationTokenLifetimePolicy -ApplicationId $applicationObjectId
56+
57+
# Remove the policy from the app
58+
Remove-MgApplicationTokenLifetimePolicyByRef -ApplicationId $applicationObjectId -TokenLifetimePolicyId $tokenLifetimePolicyId
59+
60+
# Delete the policy
61+
Remove-MgPolicyTokenLifetimePolicy -TokenLifetimePolicyId $tokenLifetimePolicyId
62+
```
63+
64+
## View existing policies in a tenant
65+
66+
To see all policies that have been created in your organization, run the [Get-MgPolicyTokenLifetimePolicy](/powershell/module/microsoft.graph.identity.signins/get-mgpolicytokenlifetimepolicy) cmdlet. Any results with defined property values that differ from the defaults listed above are in scope of the retirement.
67+
68+
```powershell
69+
Get-MgPolicyTokenLifetimePolicy
70+
```
71+
72+
To see which apps are linked to a specific policy that you identified, run [List appliesTo](/graph/api/tokenlifetimepolicy-list-appliesto) with any of your policy IDs.
73+
74+
```powershell
75+
GET https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies/4d2f137b-e8a9-46da-a5c3-cc85b2b840a4/appliesTo
76+
```
77+
78+
## Next steps
79+
Learn about [authentication session management capabilities](../conditional-access/howto-conditional-access-session-lifetime.md) in Azure AD Conditional Access.

articles/active-directory/develop/registration-config-change-token-lifetime-how-to.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

articles/active-directory/develop/scenario-web-app-call-api-acquire-token.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,26 +182,34 @@ public ModelAndView getUserFromGraph(HttpServletRequest httpRequest, HttpServlet
182182

183183
# [Python](#tab/python)
184184

185-
In the Python sample, the code that calls Microsoft Graph is in [app.py#L53-L62](https://github.com/Azure-Samples/ms-identity-python-webapp/blob/48637475ed7d7733795ebeac55c5d58663714c60/app.py#L53-L62).
186-
187-
The code attempts to get a token from the token cache. Then, after setting the authorization header, it calls the web API. If it can't get a token, it signs the user in again.
188-
189-
```python
190-
@app.route("/graphcall")
191-
def graphcall():
192-
token = _get_token_from_cache(app_config.SCOPE)
193-
if not token:
194-
return redirect(url_for("login"))
195-
graph_data = requests.get( # Use token to call downstream service.
196-
app_config.ENDPOINT,
197-
headers={'Authorization': 'Bearer ' + token['access_token']},
198-
).json()
199-
return render_template('display.html', result=graph_data)
200-
```
185+
In the Python sample, the code that calls the API is in [app.py#L60-71](https://github.com/Azure-Samples/ms-identity-python-webapp/blob/0.5.0/app.py#L60-71).
186+
187+
The code attempts to get a token from the token cache. If it can't get a token, it redirects the user to the sign-in route. Otherwise, it can proceed to call the API.
188+
189+
:::code language="python" source="~/ms-identity-python-webapp-tutorial/app.py" range="60-71":::
201190

202191
---
203192

204193
## Next steps
205194

195+
# [ASP.NET Core](#tab/aspnetcore)
196+
197+
Move on to the next article in this scenario,
198+
[Call a web API](scenario-web-app-call-api-call-api.md?tabs=aspnetcore).
199+
200+
# [ASP.NET](#tab/aspnet)
201+
206202
Move on to the next article in this scenario,
207-
[Call a web API](scenario-web-app-call-api-call-api.md).
203+
[Call a web API](scenario-web-app-call-api-call-api.md?tabs=aspnet).
204+
205+
# [Java](#tab/java)
206+
207+
Move on to the next article in this scenario,
208+
[Call a web API](scenario-web-app-call-api-call-api.md?tabs=java).
209+
210+
# [Python](#tab/python)
211+
212+
Move on to the next article in this scenario,
213+
[Call a web API](scenario-web-app-call-api-call-api.md?tabs=python).
214+
215+
---

0 commit comments

Comments
 (0)