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

.net 核心中的混合身份驗(yàn)證與 Open Id Connect 和本地

Hybrid authentication in .net core with Open Id Connect and local database(.net 核心中的混合身份驗(yàn)證與 Open Id Connect 和本地?cái)?shù)據(jù)庫(kù))
本文介紹了.net 核心中的混合身份驗(yàn)證與 Open Id Connect 和本地?cái)?shù)據(jù)庫(kù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

是否有一種模式來(lái)設(shè)計(jì)一個(gè)能夠同時(shí)使用 Open Id Connect(在 Azure AD 中連接)和本地?cái)?shù)據(jù)庫(kù)對(duì)用戶(hù)進(jìn)行身份驗(yàn)證的應(yīng)用程序?

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?

我正在創(chuàng)建的應(yīng)用程序?qū)碛衼?lái)自擁有 Azure Active Directory 的公司的用戶(hù),但也有未受雇于該公司的用戶(hù)必須使用該應(yīng)用程序,因?yàn)樗麄兾丛?Azure AD 中注冊(cè).

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.

沒(méi)有 Azure AD 的身份驗(yàn)證方法應(yīng)該使用本地?cái)?shù)據(jù)庫(kù),而不是其他身份驗(yàn)證提供程序.

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

推薦答案

您可以使用 ASP.NET Identity 來(lái)管理數(shù)據(jù)庫(kù)中的本地用戶(hù),并使用 Azure AD 作為外部身份提供者,使 AAD 帳戶(hù)能夠登錄您的應(yīng)用程序.您可以識(shí)別 Azure AD 用戶(hù)并鏈接到本地??數(shù)據(jù)庫(kù)中的用戶(hù),以便您還可以管理與本地用戶(hù)和 Azure AD 用戶(hù)的關(guān)系/角色.

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 .

我將提供一個(gè)簡(jiǎn)單的代碼示例來(lái)說(shuō)明如何實(shí)現(xiàn)該功能:

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

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

  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 身份驗(yàn)證:

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 應(yīng)用設(shè)置:

  • 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"
    },
    

    用戶(hù)在登錄過(guò)程中可以選擇本地用戶(hù)或AAD用戶(hù)登錄.

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

    這篇關(guān)于.net 核心中的混合身份驗(yàn)證與 Open Id Connect 和本地?cái)?shù)據(jù)庫(kù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!
  • 相關(guān)文檔推薦

    ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進(jìn)行身份驗(yàn)證并跨請(qǐng)求保留自定義聲明)
    ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權(quán)不起作用)
    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(如何獲取守護(hù)進(jìn)程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問(wèn)令牌和刷新令牌) - IT屋-程序員軟件開(kāi)發(fā)技
    .Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問(wèn)令牌以與 Microsoft Graph 一起使用)
    Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時(shí) Azure KeyVault Active Directory AcquireTokenAsync 超時(shí))
    主站蜘蛛池模板: 麻豆一区二区三区精品视频 | 91精品一区 | 老熟女毛片 | 国产精品2区 | 免费黄色录像视频 | 九九色综合 | 国产一区二区电影 | 一区二区三区免费 | 国产 日韩 欧美 在线 | 在线看一区二区三区 | 黄网站在线观看 | 国产精品高清一区二区三区 | 一区二区三区影院 | 亚洲vs天堂| 久久久久国产精品免费免费搜索 | 欧美日韩综合视频 | 亚洲综合二区 | 一区二区三区在线观看视频 | 久久精品免费观看 | 午夜一区二区三区 | av入口| 在线视频a | av入口 | 日韩区 | 日韩插插| 日韩午夜电影在线观看 | 伊人色综合久久天天五月婷 | 国产综合久久久 | 一级午夜aaa免费看三区 | 国产成人av在线 | 人人cao | 欧美11一13sex性hd | 综合久久久久久久 | 国产精品亚洲一区二区三区在线 | 美女福利视频网站 | 日韩中文字幕在线播放 | 欧美极品在线视频 | 成人99 | 国产精品成人一区二区三区 | 在线观看亚洲欧美 | 国产精品久久久久久亚洲调教 |