ฉันได้ลองตั้งค่าคุณสมบัติ AccessTokenLifetime สำหรับไคลเอนต์โดยนัยของฉันให้เป็น 90 วินาที ไคลเอนต์เป็นแอปพลิเคชันจาวาสคริปต์
อย่างไรก็ตาม ไคลเอ็นต์ยังคงสามารถเข้าถึงขอบเขต api "api1" ได้ประมาณ 5 นาทีหลังจากที่โทเค็นควรหมดอายุ
นี่คือรหัสสำหรับการกำหนดค่าไคลเอนต์ใน IdentityServer4:
// JavaScript Client
new Client
{
ClientId = "js",
ClientName = "JavaScript Client",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { "http://localhost:5003/callback.html" },
PostLogoutRedirectUris = { "http://localhost:5003/index.html" },
AllowedCorsOrigins = { "http://localhost:5003" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
},
AccessTokenLifetime = 90
}
ฉันใช้โซลูชันการเริ่มต้นอย่างรวดเร็วของ Javascript จาก IdentityServer github repo ที่นี่ https://github.com/IdentityServer/IdentityServer4.Samples/tree/release/Quickstarts/7_JavaScriptClient