ASP.NET Core分布式项目实战(运行Consent Page)--学习笔记
任務(wù)21:運(yùn)行Consent Page
修改 Config.cs 中的 RequireConsent 為 true,這樣登錄的時(shí)候就會(huì)跳轉(zhuǎn)到 Consent 頁(yè)面
修改 ConsentController 的 Index 為異步
[HttpGet] public async Task<IActionResult> Index(string returnUrl) {var model = await BuildConsentViewModel(returnUrl);if (model == null){}return View(model); }構(gòu)造函數(shù)改為 public
public ConsentControllerIndex.cshtml 添加用戶(hù)信息和 icon
@if (Model.IdentityScopes.Any()) {<div><span class="glyphicon glyphicon-user"></span>用戶(hù)信息</div><ul class="list-group">@foreach (var scope in Model.IdentityScopes){@Html.Partial("_ScopeListitem", scope)}</ul> }_ScopeListitem.cshtml
@using mvcCookieAuthSample.ViewModels; @model ScopeViewModel<li><label><input type="checkbox"name="ScopesConsented"id="scopes_@Model.Name"value="@Model.Name"checked="@Model.Checked"disabled="@Model.Required"/><strong>@Model.Name</strong>@if (Model.Emphasize){<span class="glyphicon glyphicon-exclamation-sign"></span>}</label>@if (string.IsNullOrEmpty(Model.Description)){<div><label for="scopes_@Model.Name">@Model.Description</label></div>} </li>啟動(dòng)服務(wù)端 mvcCookieAuthSample,再啟動(dòng)客戶(hù)端 MvcClient,登錄之后跳轉(zhuǎn)到 Consent 頁(yè)面
如果界面出現(xiàn)亂碼,可將文件 Index.cshtml 與 _ScopeListitem.cshtml 另存為 UTF-8 編碼
在 Config 的 GetClients 中補(bǔ)充客戶(hù)端信息
public static IEnumerable<Client> GetClients() {return new List<Client>{new Client(){ClientId = "client",ClientName = "Client",ClientUri = "http://localhost:5001",LogoUri = "https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQe9J82GNBVtbc0Co3IV63l4mQgRlMdn4lQI7cDmICHjA4VmFuv&usqp=CAU",AllowRememberConsent = true,AllowedGrantTypes = GrantTypes.Implicit,// 隱式模式ClientSecrets ={new Secret("secret".Sha256())},RequireConsent = true,RedirectUris = { "http://localhost:5001/signin-oidc" },PostLogoutRedirectUris = { "http://localhost:5001/signout-callback-oidc" },//AllowedScopes = {"api"},AllowedScopes ={IdentityServerConstants.StandardScopes.Profile,IdentityServerConstants.StandardScopes.OpenId,IdentityServerConstants.StandardScopes.Email,}}}; }修改 Index.cshtml,不然看不到圖片
@if (!string.IsNullOrWhiteSpace(Model.ClientLogoUrl))再次啟動(dòng)程序,顯示如下:
課程鏈接
http://video.jessetalk.cn/course/explore
相關(guān)文章
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(Consent Controller Get請(qǐng)求邏輯實(shí)現(xiàn))--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(Consent視圖制作)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(Identity Server 4回顧,Consent 實(shí)現(xiàn)思路介紹)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(oauth2 + oidc 實(shí)現(xiàn) client部分)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(oauth2 + oidc 實(shí)現(xiàn) server部分)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(oauth2與open id connect 對(duì)比)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(詳解oauth2授權(quán)碼流程)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(oauth密碼模式identity server4實(shí)現(xiàn))--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(第三方ClientCredential模式調(diào)用)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(客戶(hù)端集成IdentityServer)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(業(yè)務(wù)介紹,架構(gòu)設(shè)計(jì),oAuth2,IdentityServer4)--學(xué)習(xí)筆記
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(課程介紹,MVP,瀑布與敏捷)--學(xué)習(xí)筆記
ASP.NET Core快速入門(mén) -- 學(xué)習(xí)筆記匯總
總結(jié)
以上是生活随笔為你收集整理的ASP.NET Core分布式项目实战(运行Consent Page)--学习笔记的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ASP.NET Core on K8s学
- 下一篇: 【壹刊】Azure AD 保护的 ASP