【发布时间】:2015-09-03 08:52:56
【问题描述】:
如何从 Microsoft 的基于 OWIN 的中间件生成的 cookie 中检索 OpenID 连接令牌?
我正在使用 Microsoft.Owin.Security.Cookies 和 Microsoft.Owin.Security.OpenIdConnect 来保护使用“隐式流”的网站。有时我认为我可能能够更好地理解事物或能够排除故障,我可以检查“原始”令牌而不是从中生成的对象模型。
我了解信息是通过 Cookie 存储的,但尚未找到如何从 cookie 中检索令牌。这是一个开发环境,因此我应该可以访问所需的任何证书/机密。
我了解令牌应该有 3 个以句点分隔的段:{header}.{claims}.{signature}。如果我能找到我了解到的令牌,我可以使用jwt.io 来查看内容。但是,我的 cookie 中没有一个内容与该格式匹配。
这是我正在使用的中间件配置:
app.SetDefaultSignInAsAuthenticationType( CookieAuthenticationDefaults.AuthenticationType );
app.UseCookieAuthentication( new CookieAuthenticationOptions() );
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = stsAuthority,
RedirectUri = baseHostingPath,
ResponseType = "id_token",
Scope = string.Join( " ", "openid", "profile", "email" )
} );
【问题讨论】:
标签: c# authentication cookies owin openid-connect