久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Azure AD 作為“外部提供者"?

Azure AD as an quot;external providerquot;?(Azure AD 作為“外部提供者?)
本文介紹了Azure AD 作為“外部提供者"?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在嘗試構建一個簡單的 ASP.Net Core 2.2 Web 應用程序,它允許 AzureAD 作為外部提供者".我在 Visual Studio 2019 中執行此操作.

I'm trying to build a simple ASP.Net Core 2.2 web app that allows AzureAD as an "external provider". I'm doing this in Visual Studio 2019.

作為一個超級簡單的演示項目,我首先創建了一個使用 Azure AD 作為登錄提供程序的新項目:

As a super-simple demo project, I started by creating a new project that uses Azure AD as the login provider:

  1. 選擇 ASP.NET Core Web 應用程序
  2. 選擇 Web 應用程序(模型-視圖-控制器)
  3. 將身份驗證更改為工作或學校帳戶".它自動填寫了我的域名(因為我登錄了VS)

這將創建一個 Web 應用程序設置以在所有頁面上強制執行用戶身份驗證.當我運行應用程序時,它會轉到 Azure AD 并在導航到 /home 頁面之前讓我登錄.

This creates a web application set up to enforce user authentication on all pages. When I run the application, it goes to Azure AD and logs me in prior to navigating to the /home page.

回想一下,我說過我想將 Azure AD 添加為外部提供程序.所以我在 Startup.cs 中找到了這一行:

Recall that I said I wanted to add Azure AD as an external provider. So I found this line in Startup.cs:

services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
    .AddAzureAD(options => Configuration.Bind("AzureAd", options));

并且我刪除了默認的身份驗證方案以防止自動登錄,如下所示:

and I removed the default authentication scheme to prevent the auto-login, like this:

services.AddAuthentication()
    .AddAzureAD(options => Configuration.Bind("AzureAd", options));

現在,當我運行該應用程序時,它會導航到 Login 頁面,它會為我提供一個藍色的大按鈕,讓我可以使用 Azure Active Directory 登錄.但是點擊那個按鈕我并沒有登錄.

Now, when I run the app, it navigates to the Login page, and it gives me a big blue button offering to let me log in with Azure Active Directory. But clicking on that button does not log me in.

所以我搭建了身份頁面,并在 ExternalLogin GET 例程處設置了一個斷點.果然,點擊藍色的大按鈕會找到它的方式.單步執行代碼,我看到 _signInManager.GetExternalLoginInfoAsync() 的調用返回 null.

So I scaffolded the Identity pages, and I set a breakpoint at the ExternalLogin GET routine. Sure enough, clicking the big blue button finds its way there. Stepping through the code, I see that the call to _signInManager.GetExternalLoginInfoAsync() returns null.

我被困住了.顯然,(未記錄的)配置魔法沒有正確設置某些東西來滿足對 GetExternalLoginInfoAsync 的調用.

I'm stuck. Apparently, the (undocumented) configuration magic doesn't set something up correctly to satisfy the call to GetExternalLoginInfoAsync.

推薦答案

場景是您使用 asp.net 身份和 Azure AD 登錄作為外部身份提供者.

The scenario is you are using asp.net identity with Azure AD login as external identity provider .

您應該將 IdentityConstants.ExternalScheme 設置為 Azure AD 身份驗證的登錄架構,以便您可以通過 _signInManager.GetExternalLoginInfoAsync() 獲取外部用戶信息:p>

You should set IdentityConstants.ExternalScheme as the signin schema of Azure AD authentication , so that you can get the external user information with _signInManager.GetExternalLoginInfoAsync() :

services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(
            Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>()
    .AddDefaultUI(UIFramework.Bootstrap4)
    .AddEntityFrameworkStores<ApplicationDbContext>();

services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => Configuration.Bind("AzureAd", options));

services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options => {
    options.SignInScheme= IdentityConstants.ExternalScheme;

    //other config
});

然后您可以搭建 asp.net 身份并進行修改以滿足您的要求,在任何頁面觸發外部登錄(ExternalLogin.cshtml.cs 中的OnPost 函數)為默認模板(藍色大按鈕")可以.

Then you can scaffold the asp.net identity and modify to fit your requirement , in any page trigger external login(OnPost function in ExternalLogin.cshtml.cs) as the default template("big blue button") does .

這篇關于Azure AD 作為“外部提供者"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 91国产在线视频在线 | 亚洲国产欧美一区二区三区久久 | 国产成人精品久久久 | 亚洲精品久久久一区二区三区 | 亚洲免费人成在线视频观看 | 在线日韩欧美 | 女同久久另类99精品国产 | 久久se精品一区精品二区 | 又爽又黄axxx片免费观看 | 亚洲精品欧美一区二区三区 | 毛片区| 亚洲人成在线观看 | 91天堂| 欧美日韩看片 | 日韩在线视频一区 | 亚洲福利在线观看 | www精品美女久久久tv | 久久美国 | 国产在线aa | 国产精品99久久久久久动医院 | 成人在线视频免费看 | 日韩中文一区 | 黄视频网址 | 别c我啊嗯国产av一毛片 | 国产精品视频不卡 | 黄视频在线网站 | 亚洲欧美一区二区三区1000 | 九一在线 | 91精品国产综合久久婷婷香蕉 | 国产三区在线观看视频 | 国产成人精品免费视频大全最热 | 国产精品久久久久久久久久尿 | 日日摸夜夜添夜夜添精品视频 | 中文字幕高清 | 久久夜视频 | 欧美日韩黄色一级片 | 中文字幕精品一区二区三区精品 | 91资源在线 | 污书屋 | 成人免费视频网站在线看 | www.日本在线观看 |