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

使用密碼和 Azure Active Directory 身份驗證的 Asp.ne

Asp.net Identity using password and Azure Active Directory authentication(使用密碼和 Azure Active Directory 身份驗證的 Asp.net Identity)
本文介紹了使用密碼和 Azure Active Directory 身份驗證的 Asp.net Identity的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在使用 Asp.net Identity (OWIN) 構建一個 ASP.NET MVC 5 網站,并希望同時支持傳統的用戶名/密碼身份驗證以及針對 Azure Active Directory 的身份驗證.此應用不需要針對 Microsoft ID (Live ID)、Facebook、Twitter 或任何其他外部提供商進行身份驗證.我發現的最接近的 SO 問題是:如何在 ASP.NET MVC 上同時執行 Azure Active Directory 單點登錄和表單身份驗證

I'm building an ASP.NET MVC 5 web site using Asp.net Identity (OWIN) and want to support both traditional username/password authentication as well as authentication against Azure Active Directory. This app does not need to authenticate against Microsoft IDs (Live IDs), Facebook, Twitter or any of the other external providers. The closest SO question I found is this one: How to do both Azure Active Directory Single Sign On and Forms Authentications on ASP.NET MVC

我查看了使用 VS 2015 中的個人用戶帳戶"選項以及工作和學校帳戶"選項創建項目時創建的示例.我的身份驗證單獨運行良好;只有當我嘗試將它們結合起來時才會遇到問題.

I've looked at the samples that get created when you create a project using the "Individual User Accounts" option as well as the "Work and School Accounts" option in VS 2015. I have authentication working well individually; it's only when I try to combine them that I'm running into problems.

在我的 Startup_Auth.cs 文件中,我正在像這樣配置 OWIN:

In my Startup_Auth.cs file, I am configuring OWIN like this:

    public void ConfigureAuth(IAppBuilder app)
    {

        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        //app.UseCookieAuthentication(new CookieAuthenticationOptions { });

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
            LoginPath = new PathString("/account/sign-in")
        });

        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                ClientId = clientId,
                Authority = authority,
                TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
                {
                    ValidateIssuer = false,
                },
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                    SecurityTokenValidated = (context) => 
                    {
                        return Task.FromResult(0);
                    },
                    AuthorizationCodeReceived = (context) =>
                    {
                        return Task.FromResult(0);
                    },
                    AuthenticationFailed = (context) =>
                    {
                        context.OwinContext.Response.Redirect("/Home/Error");
                        context.HandleResponse(); // Suppress the exception
                        return Task.FromResult(0);
                    }
                }
            }
        );
    }  

此配置適用于密碼身份驗證,但不適用于 AAD 身份驗證.要啟用 AAD 身份驗證,我需要注釋掉設置 AuthenticationType 的行

This configuration works for password authentication, but doesn't work for AAD authentication. To enable AAD authentication I need to either comment out the line setting the AuthenticationType

AuthenticationType = DefaultAuthenticationTypes.ExternalCookie,

或者,只設置沒有值的 CookieAuthentication.

Or, just set CookieAuthentication with no values.

app.UseCookieAuthentication(new CookieAuthenticationOptions { });

我猜想有一個相對簡單的方法來解決這個問題,并且會很感激一些關于從哪里開始尋找的想法.

I'd guess that there is a relatively simple approach to this and would appreciate some ideas on where to start looking.

推薦答案

我搜索了微軟的例子.所有這些看起來都像您的解決方案.看這里:

I searched examples from Microsoft. And all of them look like your solution. Look here:

  1. WebApp-WSFederation-DotNet
  2. WebApp-MultiTenant-OpenIdConnect-DotNet
  3. WebApp-OpenIDConnect-DotNet

另一個例子是這里 WindowsAzureActiveDirectoryBearerAuthenticationOptions

這篇關于使用密碼和 Azure Active Directory 身份驗證的 Asp.net Identity的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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影音在线 | 狠狠操狠狠操 | 国产精品久久a | 成人av一区二区三区 | 精品一区二区三区在线观看 | 国产精品自拍视频 | 日本特黄a级高清免费大片 国产精品久久性 | 国产精品视频一二三区 | 激情网站 | 国产一区二区在线视频 | 成人深夜福利 | 欧美日韩在线免费 | 日韩午夜电影 | 久久久久久久久综合 | 精品国产一区二区 | 在线一区视频 | 成年人在线视频 | 午夜一区二区三区在线观看 | 国产成人免费视频 | 在线观看国产视频 | 99福利视频 | 免费久久久久久 | 久久久91 | 亚洲精品一区二区三区四区高清 | 欧洲亚洲视频 | 视频三区 | 户外露出一区二区三区 | 美女视频一区二区三区 | 中文字幕一区二区三区四区五区 | 国产激情视频在线 | 91性高湖久久久久久久久_久久99 | 久久国产美女视频 |