.NET Core 2.1迁移至3.1:IdentityServer类变更问题咨询
IdentityServer 从 .NET Core 2.1 迁移到 3.1 适配指南
针对迁移过程中涉及ConsentResponse和AuthorizationRequest的问题,具体适配方案如下:
ConsentResponse.ClientId 字段迁移
该字段已从ConsentResponse移至Client类,直接通过AuthorizationRequest.Client.ClientId获取即可,示例代码:var clientId = authorizationRequest.Client.ClientId;AuthorizationRequest.ScopesRequested 适配
3.1版本中ScopesRequested属性已被替换为RequestedScopes,直接使用request.RequestedScopes即可获取原请求的范围集合。ConsentResponse.Denied 写法修正
无需修改为ConsentResponse.Error.Denied,3.1版本中ConsentResponse.Denied仍然是静态只读实例,保留原写法即可:var grantedConsent = ConsentResponse.Denied;若需手动构建拒绝响应,也可实例化
ConsentResponse并设置错误类型:var grantedConsent = new ConsentResponse { Error = IdentityServer4.Models.ErrorTypes.Denied };ScopesConsented 属性替换
原代码ScopesConsented = request.ScopesRequested需替换为使用request.RequestedScopes属性,示例:var consentResponse = new ConsentResponse { ScopesConsented = request.RequestedScopes, // 其他属性设置 };
内容的提问来源于stack exchange,提问作者lakykytik
相关产品推荐
相关产品推荐

