OWIN安全性-如何实施OAuth2刷新令牌
我正在使用Visual Studio 2013随附的Web Api 2模板,该模板具有一些OWIN中间件来进行用户身份验证等。 在OAuthAuthorizationServerOptionsI中,我注意到OAuth2服务器已设置为发放在14天内到期的令牌 OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/api/token"), Provider = new ApplicationOAuthProvider(PublicClientId,UserManagerFactory) , AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), AllowInsecureHttp = true }; 这不适合我的最新项目。我想分发短暂的bearer_tokens,可以使用refresh_token 我已经进行了大量谷歌搜索,找不到任何有用的信息。 这就是我设法取得的成就。我现在已经达到“现在就做WTF”这一点。 我写了一个根据类的属性RefreshTokenProvider实现的:IAuthenticationTokenProviderRefreshTokenProviderOAuthAuthorizationServerOptions public class SimpleRefreshTokenProvider : IAuthenticationTokenProvider { private static ConcurrentDictionary<string, AuthenticationTicket> _refreshTokens = new ConcurrentDictionary<string, AuthenticationTicket>(); …