High availability · AzureAD/microsoft-authentication-library-for-dotnet Wiki · GitHub

High availability · AzureAD/microsoft-authentication-library-for-dotnet Wiki · GitHub

Pro-active token renewal

To improve availability MSAL tries to ensure than an app always has fresh unexpired tokens. AAD outages rarely take more than a few hours, so if MSAL can guarantee that a token always has at least a few hours of availability left, the application will not be impacted by the AAD outage.

To get long lived tokens, you must configure your tenant (note: internal Microsoft tenants are already configured). For client_credentials (service 2 service), this is enough. For user credentials, you must also configure CAE - https://docs.microsoft.com/en-us/azure/active-directory/conditional-access/concept-continuous-access-evaluation.

When Azure AD returns a long lived token, it includes a refresh_in field. It is generally set to half the expiration of the access token. image

Note: From MSAL 4.37.0 and above, you can observe this value by inspecting the AuthenticationResult.AuthenticationResultMetadata.RefreshOn.

Additionally, you can configure a token lifetime of more than the default 1 hour, as described [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes.

Whenever you make requests for the same token, i.e. whenever MSAL is able to serve a token from its cache, then MSAL will automatically check the refresh_in value. If it has elapsed, MSAL will issue a token request to AAD in the background, but will return the existing, valid token to the application. In the unlikely event that the background refresh fails (e.g. AAD outage), the app is not affected.

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(26)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2022-03-28 炉石传说 佣兵战纪 装备
2022-03-28 What can be the reasons of connection refused errors?
2022-03-28 Big Data & Cloud Computing: The Roles & Relationships
2020-03-28 Why can two different enum enumeration-constants have the same integer value?
2019-03-28 Singleton Pattern单例模式
2016-03-28 T4 Templates and the Entity Framework
2016-03-28 Entity Framework Utility .ttinclude File
点击右上角即可分享
微信分享提示