日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

ASP.NET Core分布式项目实战(Consent Controller Get请求逻辑实现)--学习笔记

發布時間:2023/12/4 asp.net 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ASP.NET Core分布式项目实战(Consent Controller Get请求逻辑实现)--学习笔记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

任務20:Consent Controller Get請求邏輯實現

接著上一節的思路,實現一下 ConsentController

根據流程圖在構造函數注入 IClientStore,IResourceStore,IIdentityServerInteractionService

構造函數

private readonly IClientStore _clientSotre; private readonly IResourceStore _resourceStore; private readonly IIdentityServerInteractionService _identityServerInteractionService;private ConsentController(IClientStore clientStore,IResourceStore resourceStore,IIdentityServerInteractionService identityServerInteractionService) {_clientSotre = clientStore;_resourceStore = resourceStore;_identityServerInteractionService = identityServerInteractionService; }

Index

public IActionResult Index(string returnUrl) {var model = BuildConsentViewModel(returnUrl);if (model == null){}return View(model); }

BuildConsentViewModel

private async Task<ConsentViewModel> BuildConsentViewModel(string returnUrl) {var request = await _identityServerInteractionService.GetAuthorizationContextAsync(returnUrl);if (request == null)return null;var client = await _clientSotre.FindEnabledClientByIdAsync(request.ClientId);var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ScopesRequested);return CreateConsentViewModel(request, client, resources); }

CreateConsentViewModel

private ConsentViewModel CreateConsentViewModel(AuthorizationRequest request, Client client, Resources resources) {var vm = new ConsentViewModel();vm.ClientName = client.ClientName;vm.ClientLogoUrl = client.LogoUri;vm.ClientUrl = client.ClientUri;vm.AllowRemeberConsent = client.AllowRememberConsent;vm.IdentityScopes = resources.IdentityResources.Select(i => CreateScopeViewModel(i));vm.ResourceScopes = resources.ApiResources.SelectMany(i => i.Scopes).Select(x => CreateScopeViewModel(x));return vm; }

在獲取 vm.ResourceScopes 的時候我們用到了 SelectMany,如果我們使用 resources.ApiResources.Select 的話,我們會得到一個 List<List>,而我們想要得到的是一個 List,所以通過 SelectMany 會把 List<List> 展開得到里面的每一個 List

CreateScopeViewModel

private ScopeViewModel CreateScopeViewModel(IdentityResource identityResource) {return new ScopeViewModel{Name = identityResource.Name,DisplayName = identityResource.DisplayName,Description = identityResource.Description,Required = identityResource.Required,Checked = identityResource.Required,Emphasize = identityResource.Emphasize,}; }private ScopeViewModel CreateScopeViewModel(Scope scope) {return new ScopeViewModel{Name = scope.Name,DisplayName = scope.DisplayName,Description = scope.Description,Required = scope.Required,Checked = scope.Required,Emphasize = scope.Emphasize,}; }

ConsentViewModel 添加 ClientUrl

public string ClientUrl { get; set; }

ScopeViewModel 修改字段類型為 bool

public bool Emphasize { get; set; } public bool Required { get; set; }

課程鏈接

http://video.jessetalk.cn/course/explore

相關文章

ASP.NET Core分布式項目實戰(Consent視圖制作)--學習筆記

ASP.NET Core分布式項目實戰(Identity Server 4回顧,Consent 實現思路介紹)--學習筆記

ASP.NET Core分布式項目實戰(oauth2 + oidc 實現 client部分)--學習筆記

ASP.NET Core分布式項目實戰(oauth2 + oidc 實現 server部分)--學習筆記

ASP.NET Core分布式項目實戰(oauth2與open id connect 對比)--學習筆記

ASP.NET Core分布式項目實戰(詳解oauth2授權碼流程)--學習筆記

ASP.NET Core分布式項目實戰(oauth密碼模式identity server4實現)--學習筆記

ASP.NET&nbsp;Core分布式項目實戰(第三方ClientCredential模式調用)--學習筆記

ASP.NET Core分布式項目實戰(客戶端集成IdentityServer)--學習筆記

ASP.NET Core分布式項目實戰(業務介紹,架構設計,oAuth2,IdentityServer4)--學習筆記

ASP.NET Core分布式項目實戰(課程介紹,MVP,瀑布與敏捷)--學習筆記

ASP.NET Core快速入門 -- 學習筆記匯總

總結

以上是生活随笔為你收集整理的ASP.NET Core分布式项目实战(Consent Controller Get请求逻辑实现)--学习笔记的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。