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

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

      <small id='9DDEF'></small><noframes id='9DDEF'>

      <tfoot id='9DDEF'></tfoot>

      1. 使用 Owin 從 JWT 獲取自定義聲明

        Get custom claims from a JWT using Owin(使用 Owin 從 JWT 獲取自定義聲明)

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

          <legend id='nQOrV'><style id='nQOrV'><dir id='nQOrV'><q id='nQOrV'></q></dir></style></legend><tfoot id='nQOrV'></tfoot>
            <i id='nQOrV'><tr id='nQOrV'><dt id='nQOrV'><q id='nQOrV'><span id='nQOrV'><b id='nQOrV'><form id='nQOrV'><ins id='nQOrV'></ins><ul id='nQOrV'></ul><sub id='nQOrV'></sub></form><legend id='nQOrV'></legend><bdo id='nQOrV'><pre id='nQOrV'><center id='nQOrV'></center></pre></bdo></b><th id='nQOrV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nQOrV'><tfoot id='nQOrV'></tfoot><dl id='nQOrV'><fieldset id='nQOrV'></fieldset></dl></div>
              <tbody id='nQOrV'></tbody>
                • <bdo id='nQOrV'></bdo><ul id='nQOrV'></ul>
                • 本文介紹了使用 Owin 從 JWT 獲取自定義聲明的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在使用帶有 JWTBearerAuthentication 的 Owin 來授權用戶并驗證他們的令牌.我是這樣做的:

                  I'm using Owin with JWTBearerAuthentication to authorize users and validate their tokens. I'm doing it like this:

                  public class Startup
                  {
                      public void Configuration(IAppBuilder app)
                      {
                          HttpConfiguration config = new HttpConfiguration();
                          config.MapHttpAttributeRoutes();
                  
                          config.Routes.MapHttpRoute(
                              name: "DefaultApi",
                              routeTemplate: "api/{controller}/{id}",
                              defaults: new { id = RouteParameter.Optional }
                          );
                  
                          ConfigureOAuth(app);
                          app.UseWebApi(config);
                      }
                  
                      private void ConfigureOAuth(IAppBuilder app)
                      {
                          string issuer = ConfigurationManager.AppSettings.Get("auth_issuer");
                          string audience = ConfigurationManager.AppSettings.Get("auth_clientId");
                          byte[] secret = TextEncodings.Base64Url.Decode(ConfigurationManager.AppSettings.Get("auth_secret"));
                  
                          app.UseJwtBearerAuthentication(new JwtBearerAuthenticationOptions 
                          {
                              AuthenticationMode = AuthenticationMode.Active,
                              AllowedAudiences = new [] { audience },
                              IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[]
                              {
                                  new SymmetricKeyIssuerSecurityTokenProvider(issuer, secret)
                              }
                          });
                      }
                  }
                  

                  但是,我的令牌中有一些自定義聲明,并希望在我的 ApiController 中使用它們的值,如下所示:

                  However, I have some custom claims in my token, and want to use their values in my ApiController, which looks like this:

                  [RoutePrefix("endpoint")]
                  public class MyApiController : ApiController
                  {
                      [Route("action")]
                      [Authorize]
                      public IHttpActionResult Post(string someValue)
                      {
                          bool res = DoSomeAction.withTheString(someValue);
                  
                          if (res)
                          {
                              return Ok<string>(someValue);
                          }
                  
                          return InternalServerError();
                      }
                  }
                  

                  有沒有類似 User.Claims["myCustomClaim"].Value 的東西,它提供所有聲明的值?

                  Is there anything like User.Claims["myCustomClaim"].Value, which provides the values of all claims?

                  謝謝你,盧卡斯

                  推薦答案

                  這樣的事情可能會有所幫助:

                  Something like this might help:

                  var identity = User.Identity as ClaimsIdentity;
                  
                          return identity.Claims.Select(c => new
                          {
                              Type = c.Type,
                              Value = c.Value
                          });
                  

                  這篇關于使用 Owin 從 JWT 獲取自定義聲明的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  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(從函數調用按鈕 OnClick)

                • <small id='wdGCZ'></small><noframes id='wdGCZ'>

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

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

                            <legend id='wdGCZ'><style id='wdGCZ'><dir id='wdGCZ'><q id='wdGCZ'></q></dir></style></legend>
                            <tfoot id='wdGCZ'></tfoot>
                            主站蜘蛛池模板: 欧美阿v| 在线中文字幕日韩 | 久久精品91久久久久久再现 | aaa一区| 久久精品一区二区三区四区 | 欧美精品一区二区三区视频 | 欧美狠狠操 | 99影视| 女人牲交视频一级毛片 | 国产在线一区二区三区 | 日韩一区二区不卡 | 精品中文在线 | 九九久久在线看 | 欧美日韩在线视频一区二区 | 久久成人av电影 | 亚洲精品在线看 | 高清色| 波多野结衣一区二区 | 精品久久香蕉国产线看观看亚洲 | 羞羞午夜| 美女一级毛片 | 亚洲日韩第一页 | 久久久成人动漫 | 精品一区二区三区91 | 国产精品久久久久久久久久妞妞 | 深夜爽视频 | 黄色成人免费看 | 成人超碰在线 | av性色| 久草资源在线 | 午夜视频在线免费观看 | 日韩中出| 国产欧美日韩一区 | 一区二区三区中文 | 一级片免费视频 | 色在线免费视频 | 综合色站导航 | 精品久久久久久久 | 亚洲色在线视频 | av网站观看 | 国产成人免费视频网站高清观看视频 |