[英]OWIN OAuth 2.0 - Bearer Token Never Expire
我正在使用以下OAuth提供程序和選項:
UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>(new ApplicationDbContext()));
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory),
AuthorizeEndpointPath = new PathString("/api/AccountOwin/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(2),
AllowInsecureHttp = true
};
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
Oauth Provider類來自以下鏈接: https : //github.com/gustavo-armenta/BearerTokenAuthenticationSample/blob/master/BearerTokenAuthenticationSample/Providers/ApplicationOAuthProvider.cs
我想實現Refresh令牌提供程序,因此我將到期時間設置為2分鍾。 但是我注意到,即使在2分鍾之后,WEB API也會降低對資源的訪問權限。
提前致謝!
我遇到了這個問題,因為我忘記了正確配置WebAPI。 將以下代碼添加到我的WebApiConfig Register()方法中即可解決該問題。
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
我們有同樣的問題。 在我們的案例中,事實證明身份驗證服務器是使用Web api 2.0構建的,而資源服務器是Web api 2.2。 我們首先構建了身份驗證服務器。 然后構建資源服務器。 當我們構建資源服務器並添加Nuget包時,我們獲得了Web api 2.2。 將軟件包升級到身份驗證服務器上的新版本並重新部署解決了我們的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.