OWIN Framework是否支持将承载令牌转换为cookie

时间:2017-03-07 00:23:02

标签: cookies owin bearer-token

我试图弄清楚是否有办法在OWIN Framework中获取Bearer令牌并将其转换为cookie。 OWIN框架是否也支持此cookie的验证?

1 个答案:

答案 0 :(得分:0)

添加名为BearerToken的cookieAuthenticationOption会自动为我生成此cookie。所以,我不必添加新的cookie生成器。这是我的参考代码(如果有人将来需要它):

var cookieOptions_BearerToken = new CookieAuthenticationOptions
            {
                AuthenticationType = "type2",
                CookieName = "BearerToken",
                LoginPath = new PathString("/"),
                SlidingExpiration = true,
                Provider =
                        new CookieAuthenticationProvider
                        {
                            OnValidateIdentity = OnValidateIdentityAsync_BearerToken,
                            OnException = OnCookieException,
                            OnResponseSignIn = OnResponseSignIn,
                        },
            };

            app.UseCookieAuthentication(cookieOptions_BearerToken);