如何從Microsoft基於OWIN的中間件產生的cookie中檢索OpenID連接令牌?如何從cookie中檢索OpenID Connect Identity令牌
我正在使用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")
});