久久久久久久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 超時)
主站蜘蛛池模板: a黄视频| 中文字幕一级毛片视频 | 欧美国产日韩在线观看 | 欧美国产91 | 天天弄天天操 | 两性午夜视频 | 一区二区三区四区在线视频 | 日韩福利视频 | 91免费在线 | 一区二区三区在线 | 欧 | 日韩视频在线免费观看 | 婷婷丁香综合网 | av中文在线 | 欧美精品综合 | 国产成年人小视频 | 午夜精品久久久久久久久久久久久 | 免费一区 | 国产乱码精品一区二区三区五月婷 | 亚洲毛片在线观看 | 国产伦精品一区二区三区视频金莲 | 国产精品视频www | 国产成人精品久久二区二区 | 黄色免费三级 | 成人久久 | 亚洲精品一区二区三区四区高清 | 久久久久久91香蕉国产 | 美女黄网站| 国产精品欧美一区二区三区 | 欧美日韩视频 | 亚洲精品一区二区在线观看 | 午夜欧美| 精品久久久久久久 | 亚洲精彩视频 | 欧美精品二区 | 国产高清精品在线 | 精品成人 | 亚洲一区免费在线 | 久久久久久黄 | av不卡一区 | 久久久久中文字幕 | 日韩免费高清视频 |