久久久久久久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亚洲一区 | 国产精品一区二 | 91久久久久久久久久久 | 欧美精品一区三区 | 久久久久亚洲精品 | 国产伦精品一区二区三区精品视频 | 精品自拍视频 | 国产亚洲精品久久19p | 91看片官网 | 国产视频2021 | 成人av播放 | 在线一区二区国产 | jvid精品资源在线观看 | 毛片高清| 国产精品一区二区三区免费观看 | 91精品久久久久久久久久小网站 | 国产三级日本三级 | 成年人国产在线观看 | 欧美日韩高清 | 欧美在线a| 特级黄一级播放 | 国产精品中文字幕在线播放 | 免费激情av| 欧美一级淫片007 | www.9191.com| 在线一区观看 | 欧美黄在线观看 | 欧美在线视频一区二区 | 欧美激情综合色综合啪啪五月 | 天天色综 | 国产激情一区二区三区 | 久久国产高清 | 亚洲国产精品一区 | 欧美成人精品二区三区99精品 | 久久99久久| 黄网站免费入口 | 日韩精品成人 | 日韩欧美中文 | 亚洲欧美精品在线 | 久久久久国产精品一区二区 |