第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ASP .NET Core 2.0 - JWT 外部身份驗證

ASP .NET Core 2.0 - JWT 外部身份驗證

C#
狐的傳說 2021-06-29 09:59:16
我正在嘗試開始在 ASP.NET Core 2.0 Web 應用程序上進行身份驗證。我的公司正在使用 Ping Federate,我正在嘗試使用公司登錄頁面對我的用戶進行身份驗證,并作為回報使用我的簽名密鑰(X509SecurityKey在此處)驗證返回的令牌。登錄頁面鏈接如下所示:https://companyname.com/authorization.oauth2?response_type=code&redirect_uri=https%3a%2f%2fJWTAuthExample%2fAccount%2fLogin&client_id=CompanyName.Web.JWTAuthExample&scope=&state=<...state...>開箱即用,我將 Startup.cs 配置為能夠登錄并挑戰(zhàn)此站點。我用一個裝飾我的 HomeController[Authorize(Policy="Mvc")]但是當我訪問其中一個頁面時,我只得到一個空白頁面。當我將它添加到Debug 時,它沒有命中OnChallenge或OnAuthenticationFailed方法options.Events(我認為是因為用戶需要先進行身份驗證)。那么,為了重定向到我的身份驗證網(wǎng)站,我缺少什么?它是內置的還是我必須進行一些手動配置?(注意:在其他 web 應用程序中,使用 asp net 框架,我在身份驗證失敗時在 Authorize 屬性中使用重定向)
查看完整描述

1 回答

?
catspeake

TA貢獻1111條經(jīng)驗 獲得超0個贊

按照布拉德的建議,


這是在 ASP NET 2.0 上執(zhí)行 OpenId Connect 配置的代碼示例


public void ConfigureServices(IServiceCollection services)

{

    services.AddMvc();


    services.AddAuthentication(options =>

    {

        options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;

        options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;

        options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;

    })

    .AddCookie()

    .AddOpenIdConnect(options =>

    {

        options.Authority = Configuration["AuthoritySite"];

        options.ClientId = Configuration["ClientId"];

        options.ClientSecret = Configuration["ClientSecret"];

        options.Scope.Clear();

        // options.Scope.Add("Any:Scope");

        options.ResponseType = OpenIdConnectResponseType.CodeIdTokenToken;

        options.SaveTokens = true;


        options.GetClaimsFromUserInfoEndpoint = true;


        options.TokenValidationParameters = new TokenValidationParameters

        {

            // Compensate server drift

            ClockSkew = TimeSpan.FromHours(12),

            // Ensure key

            IssuerSigningKey = CERTIFICATE,


            // Ensure expiry

            RequireExpirationTime = true,

            ValidateLifetime = true,                    


            // Save token

            SaveSigninToken = true

        };                


    });


    services.AddAuthorization(options =>

    {

        options.AddPolicy("Mvc", policy =>

        {

            policy.AuthenticationSchemes.Add(OpenIdConnectDefaults.AuthenticationScheme);

            policy.RequireAuthenticatedUser();

        });

    });

}

更多詳細信息:https : //docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/identity-2x?view=aspnetcore-2.1


查看完整回答
反對 回復 2021-07-11
  • 1 回答
  • 0 關注
  • 255 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號