Identityserver4 代码流不适用于Identity Server 4

Identityserver4 代码流不适用于Identity Server 4,identityserver4,openid-connect,.net-core-3.0,Identityserver4,Openid Connect,.net Core 3.0,我正在尝试更新我的.NET Core 3.0,以使用代码流,而不是隐式 由于Identity Server的日志中存在“无效授权代码”,因此失败 有人能告诉我哪里出了问题,或者应该检查/尝试什么吗 我需要为PKCE做些什么吗?还是把它设为真?(RequirePkce=true) 似乎在犯错前得到了公平的对待 我在前端使用oidc客户端NPM包 [13:14:44信息]调用IdentityServer端点:“IdentityServer 4.Endpoints.DiscoveryEndpoint”

我正在尝试更新我的.NET Core 3.0,以使用代码流,而不是隐式

由于Identity Server的日志中存在“无效授权代码”,因此失败

有人能告诉我哪里出了问题,或者应该检查/尝试什么吗

我需要为PKCE做些什么吗?还是把它设为真?(RequirePkce=true)

似乎在犯错前得到了公平的对待

我在前端使用oidc客户端NPM包

[13:14:44信息]调用IdentityServer端点:“IdentityServer 4.Endpoints.DiscoveryEndpoint”用于“/.well-known/openid配置”(IdentityServer 4.Hosting.IdentityServer中间件)

[13:14:44信息]调用IdentityServer端点:“IdentityServer 4.Endpoints.TokenEndpoint”for“/connect/token”(IdentityServer 4.Hosting.IdentityServer中间件)

[13:14:44信息]ClientAuthenticationSuccessEvent{ClientId:“MyProject.web”,身份验证方法:“NoSecret”,类别:“身份验证”,名称:“客户端身份验证成功”,事件类型:成功,Id:1010,消息:null,活动Id:“8000050-0007-fe00-b63f-84710c7967bb”,时间戳:09/13/2019 03:14:44,进程ID:19196,LocalIpAddress:::1:44343,RemoteIpAddress:::1“}(IdentityServer4.Events.DefaultEventService)

[13:14:44信息]令牌请求验证成功 TokenRequestValidationLog{ClientId:“MyProject.web”,ClientName:“MyProject.web”,GrantType:“authorization_code”,作用域:null,AuthorizationCode:“d473eae4ba0ca70d14ac02b1907466067ae97847cdba5f46ba78ce6a51d4c171”,RefreshToken:null,用户名:null,AuthenticationContextReferenceClass:null,租户:null,IdP:null,原始:[(“客户端id”::“MyProject.web”),(“代码”:“d473eae4ba0ca70d14ac02b1907466067ae97847cdba5f46ba78ce6a51d4c171”),(“重定向uri”:“),(“代码验证器”:“7103488868084EC4AA94A62BCB9B42EAC6FC24203EB4B14A8FDC9F3CAD9839C358780CC40C546ECB8D58AC5E118B63E”),(“授权类型”:“授权码”)}(IdentityServer4.Validation.TokenValidator)

[13:14:44信息]TokenIssuedSuccessEvent{ClientId:“MyProject.web”,ClientName:“MyProject.web”,重定向URI:null,端点:“Token”,SubjectId:null,作用域:“openid profile MyProject.webAPI”,GrantType:“authorization_code”,标记:[Token{TokenType:“id_Token”,TokenValue:*****gPHA},标记{TokenType:access_token”,TokenValue:*****YH5A“}],类别:“token”,名称:“token Issuited Success”,事件类型:Success,Id:2000,消息:null,活动Id:“80000050-0007-fe00-b63f-84710c7967bb”,时间戳:09/13/2019 03:14:44,进程Id:19196,LocalIpAddress::1:44343,RemoteIpAddress::::::”(IdentityServer4.Events.DefaultService)

[13:14:44信息]调用IdentityServer端点:“IdentityServer 4.Endpoints.UserInfoEndpoint”for“/connect/userinfo”(IdentityServer 4.Hosting.IdentityServer中间件)

[13:14:44信息]配置文件服务返回了以下声明类型:“给定名称家庭名称” (IdentityServer4.ResponseHandling.UserInformResponseGenerator)

[13:14:44信息]调用IdentityServer端点:“IdentityServer 4.Endpoints.TokenEndpoint”for“/connect/token”(IdentityServer 4.Hosting.IdentityServer中间件)

[13:14:44信息]ClientAuthenticationSuccessEvent{ClientId:“MyProject.web”,身份验证方法:“NoSecret”,类别:“身份验证”,名称:“客户端身份验证成功”,事件类型:成功,Id:1010,消息:null,活动Id:“800000C-0002-fc00-b63f-84710c7967bb”,时间戳:2019年9月13日 03:14:44,ProcessId:19196,LocalIpAddress:::1:44343,RemoteIpAddress:::1“}(IdentityServer4.Events.DefaultEventService)

[13:14:44错误]无效的授权代码{code:“d473eae4ba0ca70d14ac02b1907466067ae97847cdba5f46ba78ce6a51d4c171”},详细信息:TokenRequestValidationLog{ClientId:“MyProject.web”,客户端名称:“MyProject.web”,GrantType:“授权\ U代码”,作用域:null,授权代码:d473eae4ba0ca70d14ac02b1907466067ae97847cdba5f46ba78ce6a51d4c171”,刷新令牌:null,用户名:null,AuthenticationContextReferenceClasses:null,租户:null,IdP:null,原始:[(“客户端id:“MyProject.web”),(“代码:”d473eae4ba0ca70d14ac02b1907466067ae97847cdba5f46ba78ce6a51d4c171”),(“重定向uri”),(“代码\验证者”:”7103488868084EC4AA94A62BCB9B42EAC6FC24203EB4B14A8FDC9F3CAD9839C358780CC40C546ECB8D58AC5E118B63E),(“授权类型:”授权代码“)] (IdentityServer4.Validation.TokenRequestValidator)

[13:14:44信息]TokenIssuedFailureEvent{ClientId:“MyProject.web”,ClientName:“MyProject.web”,重定向URI:null,端点:“Token”,主题:null,作用域:null,GrantType:“授权\代码”,错误:“无效\授权”,错误描述:null,类别:“Token”,名称:“Token Issued Failure”,事件类型:失败,Id:2001,消息:null,活动Id:“800000C-0002-fc00-b63f-84710c7967bb”,时间戳:09/13/2019 03:14:44,进程Id:19196,LocalIpAddress:::1:44343,RemoteIpAddress:::1“}(IdentityServer4.Events.DefaultEventService)


下面是Identity Server 4的授权代码流的实现

public class Example
{
    public static IEnumerable<Test> Get()
    {
        var shakey = new Secret { Value = "mysecret".Sha512() };

        return new List<Test> {
            new Test {
                TestId = "authorizationCodeTest2",
                TestName = "Authorization Code Test",
                TestSecrets = new List<Secret> { shakey },
                Enabled = true,
                AllowedGrantTypes = new List<string> { "authorization_code" },
                AllowRememberConsent = false,
                RequireConsent = true,
                RedirectUris =
                  new List<string> {
                       "http://localhost:<<port>>/account/oAuth2"
                  },
                PostLogoutRedirectUris =
                  new List<string> {"http://localhost:<<port>>"},
                AllowedScopes = new List<string> {
                    "api"
                },
                AccessTokenType = AccessTokenType.Jwt
            }
        };
    }
}
公共类示例
{
公共静态IEnumerable Get()
{
var shakey=newsecret{Value=“mysecret”.Sha512()};
返回新列表{
新测试{
TestId=“authorizationCodeTest2”,
TestName=“授权码测试”,
TestSecrets=新列表{shakey},
启用=真,
AllowedGrantTypes=新列表{“授权\代码”},
AllowRememberApprove=false,
RequireSent=true,
重定向URI=
新名单{
"http://localhost:/account/oAuth2"
},
后肠直肠炎=
新列表{“http