久久久久久久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 超時)
主站蜘蛛池模板: 在线播放中文字幕 | 欧美亚洲综合久久 | 欧美精品片 | 亚洲精品久久久久久下一站 | 香蕉婷婷 | 国产小视频在线观看 | 天天操综合网站 | 中文字幕在线精品 | 亚洲国产精品久久久 | 韩日三级 | 91精品国产一区二区三区 | 国产精品二区三区 | 伊人伊人伊人 | 欧美精品一区二区三区蜜桃视频 | 国产视频中文字幕在线观看 | 成人区精品一区二区婷婷 | 成人精品一区二区三区中文字幕 | 天天射天天操天天干 | 国产99久久久国产精品 | 国产一区二 | 天天搞夜夜操 | 在线色网| 欧美成人a∨高清免费观看 91伊人 | 黑人一级片视频 | 一区 | 鲁大师一区影视 | 成人h动漫亚洲一区二区 | 日本黄色免费大片 | 中文字幕免费在线 | 日韩视频在线一区 | 免费看国产片在线观看 | 精品久久精品 | 欧美成人a∨高清免费观看 欧美日韩中 | 欧美成人免费 | 国产精品久久久久久久久久久新郎 | 免费看a| 男人影音 | 亚洲第一网站 | 中文字幕精品一区久久久久 | 理论片87福利理论电影 | 国产一区二区三区色淫影院 |