Openid 正在尝试使Thinktecture IdentityServer示例CodeFlowClient正常工作

Openid 正在尝试使Thinktecture IdentityServer示例CodeFlowClient正常工作,openid,claims-based-identity,thinktecture-ident-server,Openid,Claims Based Identity,Thinktecture Ident Server,我正在查看OIDC解决方案中的Thinktecture IdentityServer CodeFlowClient示例。我很难让它运行。它使用Thinktecture.IdentityModel.Oidc项目中定义的OpenIdConnectAuthenticationModule。在这个类中,我在从cookie中读取oidcstate时遇到问题。请参阅以下代码 // read and parse state cookie var cookie = new ProtectedCookie(Pro

我正在查看OIDC解决方案中的Thinktecture IdentityServer CodeFlowClient示例。我很难让它运行。它使用Thinktecture.IdentityModel.Oidc项目中定义的OpenIdConnectAuthenticationModule。在这个类中,我在从cookie中读取oidcstate时遇到问题。请参阅以下代码

// read and parse state cookie
var cookie = new ProtectedCookie(ProtectionMode.MachineKey);
var storedState = cookie.Read("oidcstate");
ProtectedCookie.Delete("oidcstate");

var separator = storedState.IndexOf('_');
变量storedState的值为空。我感到困惑的是,oidcstate是在OnedRequest中编写的,在AuthenticateTasync之后调用。AuthenticateTasync具有cookie读取代码。请参阅下面OnedRequest中的代码

var cookie = new ProtectedCookie(ProtectionMode.MachineKey);
cookie.Write("oidcstate", state + "_" + returnUrl, DateTime.UtcNow.AddHours(1));
没有其他地方可以写oidcstate,所以我不知道我做错了什么。如何在读取之前写入oidcstate

另外,IODClient配置上的appRelativeCallbackUrl字段是什么?它的默认值为“~/oidccallback”。在AuthenticateAsync中,它与请求AppRelativeCurrentExecutionFilePath进行比较。请参阅下面的代码

var appRelativeCallbackUrl = config.AppRelativeCallbackUrl;
if (context.Request.AppRelativeCurrentExecutionFilePath.Equals(appRelativeCallbackUrl, StringComparison.OrdinalIgnoreCase))
{
它的值应该是“~/Home”吗

如果您有任何帮助,我们将不胜感激


首先调用EndRequest—它启动到OIDC提供程序的往返—同时保持状态cookie

必须将OIDC提供程序配置为回调URL(默认情况下/oidccallback相对于应用程序根目录)


然后调用AuthenticateRequest并读回cookie。

谢谢您的回答。我迷路了,因为我正在浏览其他页面,而不是具有Authorize属性的Home/Claims。