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

      <tfoot id='Nzt6t'></tfoot>
      1. <i id='Nzt6t'><tr id='Nzt6t'><dt id='Nzt6t'><q id='Nzt6t'><span id='Nzt6t'><b id='Nzt6t'><form id='Nzt6t'><ins id='Nzt6t'></ins><ul id='Nzt6t'></ul><sub id='Nzt6t'></sub></form><legend id='Nzt6t'></legend><bdo id='Nzt6t'><pre id='Nzt6t'><center id='Nzt6t'></center></pre></bdo></b><th id='Nzt6t'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Nzt6t'><tfoot id='Nzt6t'></tfoot><dl id='Nzt6t'><fieldset id='Nzt6t'></fieldset></dl></div>
        <legend id='Nzt6t'><style id='Nzt6t'><dir id='Nzt6t'><q id='Nzt6t'></q></dir></style></legend>
        • <bdo id='Nzt6t'></bdo><ul id='Nzt6t'></ul>

        <small id='Nzt6t'></small><noframes id='Nzt6t'>

        無法使用 ASP.NET Core 從 JWT 令牌獲取聲明

        Can#39;t get claims from JWT token with ASP.NET Core(無法使用 ASP.NET Core 從 JWT 令牌獲取聲明)
        • <i id='93Jy4'><tr id='93Jy4'><dt id='93Jy4'><q id='93Jy4'><span id='93Jy4'><b id='93Jy4'><form id='93Jy4'><ins id='93Jy4'></ins><ul id='93Jy4'></ul><sub id='93Jy4'></sub></form><legend id='93Jy4'></legend><bdo id='93Jy4'><pre id='93Jy4'><center id='93Jy4'></center></pre></bdo></b><th id='93Jy4'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='93Jy4'><tfoot id='93Jy4'></tfoot><dl id='93Jy4'><fieldset id='93Jy4'></fieldset></dl></div>

          • <legend id='93Jy4'><style id='93Jy4'><dir id='93Jy4'><q id='93Jy4'></q></dir></style></legend>
              <tbody id='93Jy4'></tbody>

            <small id='93Jy4'></small><noframes id='93Jy4'>

                  <bdo id='93Jy4'></bdo><ul id='93Jy4'></ul>
                • <tfoot id='93Jy4'></tfoot>
                  本文介紹了無法使用 ASP.NET Core 從 JWT 令牌獲取聲明的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試使用 ASP.NET Core 實現(xiàn)一個非常簡單的 JWT 不記名身份驗證.我從控制器返回的響應有點像這樣:

                  I'm trying to do a really simple implementation of JWT bearer authentication with ASP.NET Core. I return a response from a controller a bit like this:

                      var identity = new ClaimsIdentity();
                      identity.AddClaim(new Claim(ClaimTypes.Name, applicationUser.UserName));
                          var jwt = new JwtSecurityToken(
                               _jwtOptions.Issuer,
                               _jwtOptions.Audience,
                               identity.Claims,
                               _jwtOptions.NotBefore,
                               _jwtOptions.Expiration,
                               _jwtOptions.SigningCredentials);
                  
                         var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt);
                  
                         return new JObject(
                             new JProperty("access_token", encodedJwt),
                             new JProperty("token_type", "bearer"),
                             new JProperty("expires_in", (int)_jwtOptions.ValidFor.TotalSeconds),
                             new JProperty(".issued", DateTimeOffset.UtcNow.ToString())
                         );
                  

                  我有用于傳入請求的 Jwt 中間件:

                  I have Jwt middleware for incoming requests:

                  app.UseJwtBearerAuthentication(new JwtBearerOptions
                  {
                       AutomaticAuthenticate = true,
                       AutomaticChallenge = true,
                       TokenValidationParameters = tokenValidationParameters
                  });
                  

                  這似乎可以使用 authorize 屬性保護資源,但聲明從未出現(xiàn).

                  This seems to work to protect resources with the authorize attribute, but the claims never show up.

                      [Authorize]
                      public async Task<IActionResult> Get()
                      {
                          var user = ClaimsPrincipal.Current.Claims; // Nothing here
                  

                  推薦答案

                  您不能在 ASP.NET Core 應用程序中使用 ClaimsPricipal.Current,因為它不是由運行時設置的.您可以閱讀 https://github.com/aspnet/Security/issues/322 了解更多信息.

                  You can't use ClaimsPricipal.Current in an ASP.NET Core application, as it's not set by the runtime. You can read https://github.com/aspnet/Security/issues/322 for more information.

                  相反,請考慮使用 ControllerBase 公開的 User 屬性.

                  Instead, consider using the User property, exposed by ControllerBase.

                  這篇關(guān)于無法使用 ASP.NET Core 從 JWT 令牌獲取聲明的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)
                  <tfoot id='WMTSr'></tfoot>

                  <i id='WMTSr'><tr id='WMTSr'><dt id='WMTSr'><q id='WMTSr'><span id='WMTSr'><b id='WMTSr'><form id='WMTSr'><ins id='WMTSr'></ins><ul id='WMTSr'></ul><sub id='WMTSr'></sub></form><legend id='WMTSr'></legend><bdo id='WMTSr'><pre id='WMTSr'><center id='WMTSr'></center></pre></bdo></b><th id='WMTSr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WMTSr'><tfoot id='WMTSr'></tfoot><dl id='WMTSr'><fieldset id='WMTSr'></fieldset></dl></div>
                    <tbody id='WMTSr'></tbody>

                    <bdo id='WMTSr'></bdo><ul id='WMTSr'></ul>

                        <small id='WMTSr'></small><noframes id='WMTSr'>

                        <legend id='WMTSr'><style id='WMTSr'><dir id='WMTSr'><q id='WMTSr'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 天天精品在线 | 亚洲高清视频一区 | 一区二区在线观看免费视频 | 久久久久国产一区二区三区不卡 | 韩日一区 | 日韩视频一区二区 | 亚洲欧洲日本国产 | 久久久久久久久久久高潮一区二区 | 91精品国产综合久久久久 | 中文久久 | 日韩淫片免费看 | 在线日韩视频 | 在线视频亚洲 | 国产亚洲成av人片在线观看桃 | 亚洲91| 国产一二三区电影 | 欧美性大战久久久久久久蜜臀 | 国产一级免费视频 | 日本aa毛片a级毛片免费观看 | 亚洲精品福利视频 | 国产成人综合亚洲欧美94在线 | 欧美中文在线 | 福利社午夜影院 | 麻豆久久久9性大片 | 正在播放国产精品 | av片在线观看网站 | 久久人 | 国产99视频精品免视看9 | 在线播放中文字幕 | 中文字幕国产视频 | 亚洲精品中文字幕在线 | 91精品在线看 | 亚洲激情网站 | 色视频在线播放 | 性高湖久久久久久久久3小时 | 亚洲综合字幕 | 日韩日韩日韩日韩日韩日韩日韩 | 91精品一区二区三区久久久久久 | 亚洲一区二区三区在线 | 免费爱爱视频 | 亚洲精品www |