【发布时间】:2021-06-09 01:22:47
【问题描述】:
我已经创建了这个身份服务器 4 项目,它可以在我的机器上本地运行,并且在我将它部署到我公司的内部服务器(生产)时也可以运行。现在,当我将部署的应用程序从我们的内部服务器移动到实时(外部)服务器时,我遇到了一个让我非常困惑的问题 当我尝试从 api 获取数据时出现此错误,因为我能够成功登录,甚至获得了令牌。当我检查 idp 日志文件时,我得到以下信息:
[04:36:03 信息] 启动主机...
[04:36:04 信息] IdentityServer4.Startup 启动 IdentityServer4版本4.0.2+58e6bc8a94236b81d1d3c606c8295203c7c1c9e2
[04:36:04 信息] IdentityServer4.Startup 使用默认 IdentityServer的身份验证方案Identity.Application
[04:36:04 调试] IdentityServer4.Startup 使用 Identity.Application 作为 用于身份验证的默认 ASP.NET Core 方案
[04:36:04 调试] IdentityServer4.Startup 使用 Identity.External 作为 用于登录的默认 ASP.NET Core 方案
[04:36:04 调试] IdentityServer4.Startup 使用 Identity.External 作为 用于注销的默认 ASP.NET Core 方案
[04:36:04 调试] IdentityServer4.Startup 使用 Identity.Application 作为 挑战的默认 ASP.NET Core 方案
[04:36:04 调试] IdentityServer4.Startup 使用 Identity.Application 作为 禁止的默认 ASP.NET Core 方案
[04:36:04 信息] Microsoft.Hosting.Lifetime 现在收听: http://127.0.0.1:39619
[04:36:04 信息] Microsoft.Hosting.Lifetime 应用程序已启动。 按 Ctrl+C 关闭。
[04:36:04 信息] Microsoft.Hosting.Lifetime 托管环境: 生产
[04:36:04 信息] Microsoft.Hosting.Lifetime 内容根路径: C:\inetpub\wwwroot\TaxRevenueIdp
[04:36:04 调试] IdentityServer4.Startup 登录网址:/Account/Login
[04:36:04 Debug] IdentityServer4.Startup Login Return Url 参数: 返回网址
[04:36:04 调试] IdentityServer4.Startup 注销网址:/Account/Logout
[04:36:04 调试] IdentityServer4.Startup ConsentUrl Url: /consent
[04:36:04 Debug] IdentityServer4.Startup同意返回Url参数: 返回网址
[04:36:04 调试] IdentityServer4.Startup 错误网址:/home/error
[04:36:04 Debug] IdentityServer4.Startup Error Id 参数:errorId
[04:36:05 调试] IdentityServer4.Hosting.EndpointRouter 请求路径 /connect/authorize 匹配端点类型 Authorize
[04:36:05 调试] IdentityServer4.Hosting.EndpointRouter 端点 启用:授权,成功创建处理程序: IdentityServer4.Endpoints.AuthorizeEndpoint
[04:36:05 信息] IdentityServer4.Hosting.IdentityServerMiddleware 调用 IdentityServer 端点:IdentityServer4.Endpoints.AuthorizeEndpoint 对于/连接/授权
[04:36:05 调试] IdentityServer4.Endpoints.AuthorizeEndpoint 开始 授权请求
[04:36:05 调试] IdentityServer4.Endpoints.AuthorizeEndpoint 用户在 授权请求:00b6146c-0770-4c20-a29b-8427c37d4c99
[04:36:05 调试] IdentityServer4.Validation.AuthorizeRequestValidator 开始授权请求协议验证
[04:36:05 调试] IdentityServer4.EntityFramework.Stores.ClientStore 在数据库中找到 TaxAdminCode: True
[04:36:05 调试] IdentityServer4.Stores.ValidatingClientStore 客户端 客户端 TaxAdminCode 的配置验证成功。
[04:36:05 调试] IdentityServer4.Validation.AuthorizeRequestValidator 检查 PKCE 参数
[04:36:05 调试] IdentityServer4.Validation.AuthorizeRequestValidator 没有使用 PKCE。
[04:36:05 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["profile", "openid", "email"] 身份范围
[04:36:05 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["collectorapi"] API 资源
[04:36:05 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["collectorapi"] 范围
[04:36:05 调试] IdentityServer4.Validation.AuthorizeRequestValidator 调用自定义验证器: IdentityServer4.Validation.DefaultCustomAuthorizeRequestValidator
[04:36:05 调试] IdentityServer4.Endpoints.AuthorizeEndpoint ValidatedAuthorizeRequest {"ClientId": "TaxAdminCode", "ClientName": “税务管理代码”,“RedirectUri”: "https:///PersolTaxService", “AllowedRedirectUris”: ["https://.../PersolTaxService/signin-oidc"], “SubjectId”:“00b6146c-0770-4c20-a29b-8427c37d4c99”,“ResponseType”: “代码”,“响应模式”:“查询”,“GrantType”:“授权代码”, "RequestedScopes": "collectorapi profile openid email", "State": null, "UiLocales": null, "Nonce": null, “AuthenticationContextReferenceClasses”:null,“DisplayMode”:null, “PromptMode”:“”,“MaxAge”:null,“LoginHint”:null,“SessionId”: “04847BC7FEBA51BF79477CAB9931AC35”,“原始”:{“response_type”:“代码”, “状态”:“”,“client_id”:“TaxAdminCode”,“范围”:“collectorapi” 配置文件 openid 电子邮件”,“redirect_uri”: "https://.../PersolTaxService"}, "$type": "授权请求验证日志"}
[04:36:05 调试] IdentityServer4.Services.DefaultConsentService 客户端 配置为不需要同意,不需要同意
[04:36:05 调试] IdentityServer4.ResponseHandling.AuthorizeResponseGenerator 创建 授权码流响应。
[04:36:05 调试] IdentityServer4.EntityFramework.Stores.PersistedGrantStore 2czi9SJKgRsF3kn39k7qgm9rgolATlMmAhlI464hJIs= 未在数据库中找到
[04:36:06 信息] IdentityServer4.Events.DefaultEventService {“ClientId”:“TaxAdminCode”,“ClientName”:“税务管理代码”, "RedirectUri": "https://.../PersolTaxService", “端点”:“授权”、“SubjectId”: “00b6146c-0770-4c20-a29b-8427c37d4c99”,“范围”:“collectorapi profile openid email", "GrantType": "authorization_code", "Tokens": [{"TokenType": "code", "TokenValue": "****70F2", "$type": "Token"}], “类别”:“令牌”,“名称”:“令牌颁发成功”,“事件类型”: “成功”,“Id”:2000,“消息”:null,“ActivityId”: “0HM2JM2P8F6QO:00000001”,“时间戳”:“2020-09-08T04:36:06.0000000Z”, “ProcessId”:15124,“LocalIpAddress”:“127.0.0.1:39619”, “RemoteIpAddress”:“154.160.19.136”,“$type”: "TokenIssuedSuccessEvent"}
[04:36:06 调试] IdentityServer4.Endpoints.AuthorizeEndpoint 授权 端点响应 {"SubjectId": "00b6146c-0770-4c20-a29b-8427c37d4c99", "ClientId": "TaxAdminCode", "RedirectUri": "https://.../PersolTaxService", “状态”:空,“范围”:“collectorapi 配置文件 openid 电子邮件”,“错误”: null, "ErrorDescription": null, "$type": "AuthorizeResponseLog"}
[04:36:06 调试] IdentityServer4.Hosting.IdentityServerAuthenticationService 增强 登录上下文
[04:36:06 信息] Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler AuthenticationScheme:Identity.Application 已登录。
[04:36:06 调试] IdentityServer4.Hosting.EndpointRouter 请求路径 /connect/token 与端点类型 Token 匹配
[04:36:06 调试] IdentityServer4.Hosting.EndpointRouter 端点 启用:令牌,成功创建处理程序: IdentityServer4.Endpoints.TokenEndpoint
[04:36:06 信息] IdentityServer4.Hosting.IdentityServerMiddleware 调用 IdentityServer 端点:IdentityServer4.Endpoints.TokenEndpoint 用于 /连接/令牌
[04:36:06 调试] IdentityServer4.Endpoints.TokenEndpoint 开始令牌 请求。
[04:36:06 调试] IdentityServer4.Validation.ClientSecretValidator 开始客户端验证
[04:36:06 调试] IdentityServer4.Validation.BasicAuthenticationSecretParser 启动 解析基本身份验证密钥
[04:36:06 调试] IdentityServer4.Validation.ISecretsListParser 解析器 发现秘密:BasicAuthenticationSecretParser
[04:36:06 调试] IdentityServer4.Validation.ISecretsListParser Secret 找到的 ID:TaxAdminCode
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ClientStore 在数据库中找到 TaxAdminCode: True
[04:36:06 调试] IdentityServer4.Stores.ValidatingClientStore 客户端 客户端 TaxAdminCode 的配置验证成功。
[04:36:06 调试] IdentityServer4.Validation.ClientSecretValidator 公共客户端 - 跳过秘密验证成功
[04:36:06 调试] IdentityServer4.Validation.ClientSecretValidator 客户端验证成功
[04:36:06 信息] IdentityServer4.Events.DefaultEventService {“ClientId”:“TaxAdminCode”,“AuthenticationMethod”:“SharedSecret”, “类别”:“身份验证”,“名称”:“客户端身份验证成功”, “EventType”:“成功”,“Id”:1010,“Message”:空,“ActivityId”: “0HM2JM2P8F6QO:00000002”,“时间戳”:“2020-09-08T04:36:06.0000000Z”, “ProcessId”:15124,“LocalIpAddress”:“127.0.0.1:39619”, “RemoteIpAddress”:“154.160.19.136”,“$type”: "ClientAuthenticationSuccessEvent"}
[04:36:06 调试] IdentityServer4.Validation.TokenRequestValidator 开始令牌请求验证
[04:36:06 调试] IdentityServer4.Validation.TokenRequestValidator 开始验证授权码令牌请求
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.PersistedGrantStore 2czi9SJKgRsF3kn39k7qgm9rgolATlMmAhlI464hJIs= 在数据库中找到:真
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.PersistedGrantStore 删除 2czi9SJKgRsF3kn39k7qgm9rgolATlMmAhlI464hJIs= 持续授权来自 数据库
[04:36:06 调试] IdentityServer4.Validation.TokenRequestValidator 验证授权码token请求成功
[04:36:06 信息] IdentityServer4.Validation.TokenRequestValidator 令牌请求 验证成功,{“ClientId”:“TaxAdminCode”,“ClientName”:“Tax 管理员代码”,“GrantType”:“授权代码”,“范围”:空, “授权码”: "06E8389B3304937E176059F68E9DDA389FAC86D0C1C0D97C9851D96F29E270F2", “刷新令牌”:空,“用户名”:空, “AuthenticationContextReferenceClasses”:空,“租户”:空,“IdP”: 空,“原始”:{“grant_type”:“授权代码”,“代码”: "06E8389B3304937E176059F68E9DDA389FAC86D0C1C0D97C9851D96F29E270F2", “redirect_uri”: “https://.../PersolTaxService”、“client_id”: "TaxAdminCode"}, "$type": "TokenRequestValidationLog"}
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ClientStore 在数据库中找到 TaxAdminCode: True
[04:36:06 调试] IdentityServer4.Stores.ValidatingClientStore 客户端 客户端 TaxAdminCode 的配置验证成功。
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["profile", "openid", "email"] 身份范围
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["collectorapi"] API 资源
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["collectorapi"] 范围
[04:36:06 调试] IdentityServer4.Services.DefaultClaimsService 获取 为客户申请访问令牌:TaxAdminCode
[04:36:06 调试] IdentityServer4.Services.DefaultClaimsService 获取 主题的访问令牌声明: 00b6146c-0770-4c20-a29b-8427c37d4c99
[04:36:06 调试] IdentityServer4.Services.DefaultClaimsService 声明 已过滤的配置文件服务中的类型:["sub", "amr", "idp", "auth_time"]
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ClientStore 在数据库中找到 TaxAdminCode: True
[04:36:06 调试] IdentityServer4.Stores.ValidatingClientStore 客户端 客户端 TaxAdminCode 的配置验证成功。
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["profile", "openid", "email"] 身份范围
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["collectorapi"] API 资源
[04:36:06 调试] IdentityServer4.EntityFramework.Stores.ResourceStore 在数据库中找到 ["collectorapi"] 范围
[04:36:06 调试] IdentityServer4.Services.DefaultClaimsService 获取 主题的身份令牌声明: 00b6146c-0770-4c20-a29b-8427c37d4c99 和客户:TaxAdminCode
[04:36:06 调试] IdentityServer4.Services.DefaultClaimsService 声明 已过滤的配置文件服务中的类型:["sub", "amr", "idp", "auth_time"]
[04:36:06 信息] IdentityServer4.Events.DefaultEventService {“ClientId”:“TaxAdminCode”,“ClientName”:“税务管理代码”, "RedirectUri": null, "Endpoint": "Token", "SubjectId": “00b6146c-0770-4c20-a29b-8427c37d4c99”,“范围”:“collectorapi profile openid email", "GrantType": "authorization_code", "Tokens": [{“TokenType”:“id_token”,“TokenValue”:“****Mj6A”,“$type”: "Token"}, {"TokenType": "access_token", "TokenValue": "****zTOg", "$type": "Token"}], "Category": "Token", "Name": "Token Issued 成功”,“EventType”:“成功”,“Id”:2000,“消息”:null, “ActivityId”:“0HM2JM2P8F6QO:00000002”,“时间戳”: “2020-09-08T04:36:06.0000000Z”,“ProcessId”:15124,“LocalIpAddress”: “127.0.0.1:39619”、“RemoteIpAddress”:“154.160.19.136”、“$type”: "TokenIssuedSuccessEvent"}
[04:36:06 调试] IdentityServer4.Endpoints.TokenEndpoint 令牌请求 成功。
我怀疑 RedirectUri 在此级别 IdentityServer4.Events.DefaultEventService 为空。 我真的不知道如何解决这个问题,而且 api 应用程序中的日志文件也没有加载任何内容。 所以任何帮助将不胜感激。 谢谢
【问题讨论】:
标签: c# android entity-framework authentication identityserver4