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

      <tfoot id='jeXxh'></tfoot>

      1. <legend id='jeXxh'><style id='jeXxh'><dir id='jeXxh'><q id='jeXxh'></q></dir></style></legend>

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

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

        Jwt Bearer 和依賴注入

        Jwt Bearer and dependency injection(Jwt Bearer 和依賴注入)
        • <tfoot id='chZyi'></tfoot>

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

                <bdo id='chZyi'></bdo><ul id='chZyi'></ul>
                  <tbody id='chZyi'></tbody>
                • <legend id='chZyi'><style id='chZyi'><dir id='chZyi'><q id='chZyi'></q></dir></style></legend>
                  <i id='chZyi'><tr id='chZyi'><dt id='chZyi'><q id='chZyi'><span id='chZyi'><b id='chZyi'><form id='chZyi'><ins id='chZyi'></ins><ul id='chZyi'></ul><sub id='chZyi'></sub></form><legend id='chZyi'></legend><bdo id='chZyi'><pre id='chZyi'><center id='chZyi'></center></pre></bdo></b><th id='chZyi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='chZyi'><tfoot id='chZyi'></tfoot><dl id='chZyi'><fieldset id='chZyi'></fieldset></dl></div>
                • 本文介紹了Jwt Bearer 和依賴注入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試配置我的 Jwt Bearer 頒發者密鑰,但在生產中,我通常使用由 KeyManager 包裝的 Azure Key Vault.KeyManager 類是在依賴注入中配置的,但是在 ConfigureServices 方法中我不能使用它(顯然),但是如果我不能使用它,我就無法檢索我的密鑰.

                  I am trying to configure my Jwt Bearer issuer key but, in production usually, I use Azure Key Vault wrapped by a KeyManager. The KeyManager class is configured in Dependency Injection but, in ConfigureServices method I cannot use that (obviously), but if I cannot use that I cannot retrieve my key.

                  我目前的解決方案是建立一個臨時服務提供者并使用它,但我認為不是最先進的(我需要創建兩個單例副本,不是最好的).

                  My solution at the moment is to build a temporary service provider and use it, but I think is not the state of the art (and I need to create two copies of singletons, not the best).

                  services.AddAuthentication(options =>
                  {
                      options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                      options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                      options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
                  }).AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
                  {
                      ServiceProvider sp = services.BuildServiceProvider();
                      IKeyManager keyManager = sp.GetService<KeyManager>();
                  
                      options.TokenValidationParameters = new TokenValidationParameters
                      {
                          ValidateIssuerSigningKey = true,
                          IssuerSigningKey = keyManager.GetSecurityKeyFromName("jwt").Result,
                  
                          ValidIssuer = "https://api.example.com",
                          ValidateIssuer = true
                      };
                  
                      options.Audience = "https://api.example.com";
                      options.Authority = "https://api.example.com";
                  
                      options.SaveToken = true;
                  });
                  

                  推薦答案

                  使用 選項模式并實現IConfigureNamedOptions<JwtBearerOptions>:

                  public class ConfigureJwtBearerOptions : IConfigureNamedOptions<JwtBearerOptions>
                  {
                      private readonly IKeyManager _keyManager;
                  
                      public ConfigureJwtBearerOptions(IKeyManager keyManager)
                      {
                          _keyManager = keyManager;
                      }
                  
                      public void Configure(JwtBearerOptions options)
                      {
                          options.TokenValidationParameters = new TokenValidationParameters
                          {
                              ValidateIssuerSigningKey = true,
                              IssuerSigningKey = _keyManager.GetSecurityKeyFromName("jwt").Result,
                  
                              ValidIssuer = "https://api.example.com",
                              ValidateIssuer = true
                          };
                  
                          options.Audience = "https://api.example.com";
                          options.Authority = "https://api.example.com";
                  
                          options.SaveToken = true;
                      }
                  
                      public void Configure(string name, JwtBearerOptions options)
                      {
                          Configure(options);
                      }
                  }
                  

                  Startup.cs中:

                  services.AddAuthentication(options =>
                  {
                      options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                      options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                      options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
                  }).AddJwtBearer();
                  
                  services.ConfigureOptions<ConfigureJwtBearerOptions>();
                  

                  這篇關于Jwt Bearer 和依賴注入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                    • <bdo id='i4Ezg'></bdo><ul id='i4Ezg'></ul>

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

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

                            主站蜘蛛池模板: 天天夜天天操 | 欧美理论片在线观看 | www.玖玖玖| av天天干| 国产精品成人一区二区三区夜夜夜 | 日韩电影免费观看中文字幕 | 成人午夜视频在线观看 | 欧美日韩国产精品一区二区 | 久久久久久久国产精品影院 | 91在线视频免费观看 | 久久综合婷婷 | 一区视频在线免费观看 | 天堂中文字幕av | 欧美网站一区二区 | 亚洲综合日韩精品欧美综合区 | 久久一| 亚洲精品一区二区三区蜜桃久 | 亚洲精品一区二区二区 | 日韩精品免费在线观看 | 成人在线免费视频 | jlzzjlzz欧美大全 | 欧美a在线看 | 欧美日韩免费一区二区三区 | 久久成人综合 | 国产一区二区三区视频 | 国产精品一区二区av | 亚洲精品久久久久中文字幕二区 | 国产毛片在线看 | 精品蜜桃一区二区三区 | www.夜夜骑 | 日本高清不卡视频 | 国产在线a | 中文字幕一区二区三区四区不卡 | 国产成人99久久亚洲综合精品 | 日韩一级免费大片 | 国产精品国产三级国产aⅴ中文 | 91精品国产综合久久香蕉麻豆 | 国产在线播 | 欧美影院久久 | 久久不射电影网 | 色伊人久久 |