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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

從外部訪問 User.Identity 和 Claims

從外部訪問 User.Identity 和 Claims

C#
達(dá)令說 2021-07-27 21:08:53
我正在嘗試使用 OpenID Connect 構(gòu)建 SSO(.net core) 服務(wù),這將是 Webforms 應(yīng)用程序和服務(wù)提供者之間的一個(gè)層。我創(chuàng)建了一些端點(diǎn)來檢查用戶是否通過身份驗(yàn)證并從服務(wù)中獲取用戶聲明。當(dāng)我從瀏覽器調(diào)用這些端點(diǎn)時(shí),我能夠獲得正確的結(jié)果。但是,當(dāng)我從網(wǎng)站(使用 HttpWebRequest)調(diào)用它們時(shí)。User.Identity總是空的。我用來檢查用戶是否通過身份驗(yàn)證的端點(diǎn)如下所示:[HttpGet][Route("IsAuthenticated")]public IActionResult IsAuthenticated(){    return Json(User.Identity.IsAuthenticated);}或者獲取訪問令牌:[HttpGet][Route("access_token")]public async Task<IActionResult> AccessToken(){    var tokenResult = await HttpContext.GetTokenAsync("access_token");    return Json(tokenResult);}我的啟動(dòng) ConfigureServices 看起來像這樣:var OIDCConfiguration = new OIDCSettings(){    Authority = Configuration["OIDCSettings:Authority"],    ClientId = Configuration["OIDCSettings:ClientId"],    ClientSecret = Configuration["OIDCSettings:ClientSecret"],    CallbackPath = Configuration["OIDCSettings:CallbackPath"],    UserInfoEndpoint = Configuration["OIDCSettings:UserInfoEndpoint"]};services.AddAuthentication(options => {    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;    options.DefaultChallengeScheme = "oidc";}).AddCookie(CookieAuthenticationDefaults.AuthenticationScheme).AddOpenIdConnect("oidc", options => {    options.Authority = OIDCConfiguration.Authority;    options.ClientId = OIDCConfiguration.ClientId;    options.ClientSecret = OIDCConfiguration.ClientSecret;    options.CallbackPath = new PathString(OIDCConfiguration.CallbackPath);    options.ResponseType = OpenIdConnectResponseType.Code;    options.GetClaimsFromUserInfoEndpoint = true;    options.Scope.Add("openid emailAddress");    options.AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet;    options.SaveTokens = true;});為了啟動(dòng)中間件,我使用了 ChallengeResult 對(duì)象。我是 OpenID Connect 和中間件架構(gòu)的初學(xué)者,所以我不確定我缺少什么,或者我的架構(gòu)是否正確。
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 259 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)