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

.net 核心中的混合身份驗證與 Open Id Connect 和本地

Hybrid authentication in .net core with Open Id Connect and local database(.net 核心中的混合身份驗證與 Open Id Connect 和本地數據庫)
本文介紹了.net 核心中的混合身份驗證與 Open Id Connect 和本地數據庫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

是否有一種模式來設計一個能夠同時使用 Open Id Connect(在 Azure AD 中連接)和本地數據庫對用戶進行身份驗證的應用程序?

Is there a pattern to design an app who's cappable of authenticate users with both Open Id Connect (connected in Azure AD) and a local database?

我正在創建的應用程序將擁有來自擁有 Azure Active Directory 的公司的用戶,但也有未受雇于該公司的用戶必須使用該應用程序,因為他們未在 Azure AD 中注冊.

The app I'm creating will have users from a company that does has an Azure Active Directory, but also has users not employed by said company who must use the app since they are not registred in Azure AD.

沒有 Azure AD 的身份驗證方法應該使用本地數據庫,而不是其他身份驗證提供程序.

The authentication method without the Azure AD should use a local database, not other authentication providers.

推薦答案

您可以使用 ASP.NET Identity 來管理數據庫中的本地用戶,并使用 Azure AD 作為外部身份提供者,使 AAD 帳戶能夠登錄您的應用程序.您可以識別 Azure AD 用戶并鏈接到本地??數據庫中的用戶,以便您還可以管理與本地用戶和 Azure AD 用戶的關系/角色.

You can use ASP.NET Identity for managing your local users in database ,and use Azure AD as external identity provider which enable the AAD accounts to login in your application . You can identify the Azure AD user and link to a user in your local DB , so that you can also manage relationship/roles both with your local users and Azure AD users .

我將提供一個簡單的代碼示例來說明如何實現該功能:

I will provide a simple code sample for how to implement that feature :

  1. 使用 ASP.NET Identity(Individual User Accounts 模板)創建新的 .net 核心應用程序.

  1. Create new .net core application with ASP.NET Identity (Individual User Accounts template).

安裝包:Microsoft.AspNetCore.Authentication.AzureAD.UI

Install the package : Microsoft.AspNetCore.Authentication.AzureAD.UI

修改 Startup.cs 以啟用 Azure AD 身份驗證:

Modify the Startup.cs to enable Azure AD Authentication:

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

services.AddAuthentication(sharedOptions =>
{

}).AddAzureAD(options => Configuration.Bind("AzureAd", options)).AddCookie();

  • 修改 appsettings.json 以添加 Azure AD 應用設置:

  • Modify the appsettings.json to add the Azure AD app settings:

    "AzureAd": {
        "Instance": "https://login.microsoftonline.com/",
        "Domain": "xxx.onmicrosoft.com",
        "TenantId": "xxxxxx-xxxxx-4f08-b544-b1eb456f228d",
        "ClientId": "xxxxx-xxxxx-4717-9821-e4f718fbece4",
        "CallbackPath": "/signin-oidc",
        "CookieSchemeName": "Identity.External"
    },
    

    用戶在登錄過程中可以選擇本地用戶或AAD用戶登錄.

    Users could choose login with local user or AAD user during the login process .

    這篇關于.net 核心中的混合身份驗證與 Open Id Connect 和本地數據庫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 超時)
    主站蜘蛛池模板: 久久怡红院 | 国产精品日韩欧美 | 亚洲人成在线播放 | 99热精品在线观看 | 国产视频一区二区在线播放 | 日韩欧美国产精品 | 国产成人精品一区二区三区福利 | 欧美午夜在线观看 | 亚洲天堂久久 | 亚洲一区二区在线播放 | 欧美激情亚洲 | 天天干天天爽 | www.青青草| 国产精品久久网 | 日韩成人在线免费观看 | 亚洲免费二区 | 久热精品视频 | 日日日操操操 | 成人欧美一区二区三区黑人孕妇 | 天天草天天射 | 成人小视频在线观看 | 国产美女自拍视频 | 日韩高清精品免费观看 | 九九视频在线 | 国产精品伊人 | 色综合小说 | 国产在线视频网站 | av老司机在线 | 亚洲精品久久久久久久久久久 | 综合久久久 | 欧美视频在线观看 | 国产一区一区 | 午夜国产| 国产精品一区二区在线 | 成人免费看片视频 | 日韩精品在线一区二区 | 91tv国产成人福利 | 日本在线视频一区 | 亚洲精品1| 久久精品一区二区三区不卡牛牛 | 特一级黄色片 |