久久久久久久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 超時)
    主站蜘蛛池模板: 亚洲精品一二三区 | 成人网av | 高清人人天天夜夜曰狠狠狠狠 | 成人久久久 | 成人高清在线 | 亚洲导航深夜福利涩涩屋 | 久久久久国色av免费观看性色 | 国产精品久久国产精品 | 在线观看日韩精品视频 | 成人福利在线观看 | 二区在线观看 | 精品一区二区在线看 | 91在线观看视频 | a在线观看免费 | 久久免费视频2 | 一区二区三区精品视频 | 久久久成人免费一区二区 | 青青久视频 | 日韩中文字幕在线视频 | 久久精品手机视频 | 欧美jizzhd精品欧美巨大免费 | 欧美乱操| 国产精品久久国产精品久久 | 九九久久久久久 | 国产一区在线免费观看 | 欧美一级二级视频 | 久久er精品 | 亚洲视频一区在线播放 | 91超碰在线观看 | 精品视频在线免费观看 | 国产美女一区二区 | 欧美xxxx网站 | 91视频88av| 国产在线看片 | 手机看片在线播放 | 久久久高清 | 国产高清精品网站 | 久久综合香蕉 | 特级毛片 | 精品国产一区二区三区免费 | 久久精品综合 |