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

      • <bdo id='5ZY6r'></bdo><ul id='5ZY6r'></ul>
    1. <tfoot id='5ZY6r'></tfoot>
      <i id='5ZY6r'><tr id='5ZY6r'><dt id='5ZY6r'><q id='5ZY6r'><span id='5ZY6r'><b id='5ZY6r'><form id='5ZY6r'><ins id='5ZY6r'></ins><ul id='5ZY6r'></ul><sub id='5ZY6r'></sub></form><legend id='5ZY6r'></legend><bdo id='5ZY6r'><pre id='5ZY6r'><center id='5ZY6r'></center></pre></bdo></b><th id='5ZY6r'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5ZY6r'><tfoot id='5ZY6r'></tfoot><dl id='5ZY6r'><fieldset id='5ZY6r'></fieldset></dl></div>
    2. <small id='5ZY6r'></small><noframes id='5ZY6r'>

      <legend id='5ZY6r'><style id='5ZY6r'><dir id='5ZY6r'><q id='5ZY6r'></q></dir></style></legend>
    3. 在 ASP.NET Core 的 Swagger 中使用 JWT(授權:Bearer)

      Use JWT (Authorization: Bearer) in Swagger in ASP.NET Core(在 ASP.NET Core 的 Swagger 中使用 JWT(授權:Bearer))
      • <legend id='S8k8Z'><style id='S8k8Z'><dir id='S8k8Z'><q id='S8k8Z'></q></dir></style></legend>

                <tbody id='S8k8Z'></tbody>

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

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

                <tfoot id='S8k8Z'></tfoot>
              • <i id='S8k8Z'><tr id='S8k8Z'><dt id='S8k8Z'><q id='S8k8Z'><span id='S8k8Z'><b id='S8k8Z'><form id='S8k8Z'><ins id='S8k8Z'></ins><ul id='S8k8Z'></ul><sub id='S8k8Z'></sub></form><legend id='S8k8Z'></legend><bdo id='S8k8Z'><pre id='S8k8Z'><center id='S8k8Z'></center></pre></bdo></b><th id='S8k8Z'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='S8k8Z'><tfoot id='S8k8Z'></tfoot><dl id='S8k8Z'><fieldset id='S8k8Z'></fieldset></dl></div>
                本文介紹了在 ASP.NET Core 的 Swagger 中使用 JWT(授權:Bearer)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我正在 ASP.NET Core 1.0 中創建一個 REST api.我使用 Swagger 進行測試,但現在我為某些路由添加了 JWT 授權.(使用 UseJwtBearerAuthentication)

                I'm creating a REST api in ASP.NET Core 1.0. I was using Swagger to test but now I added JWT authorization for some routes. (with UseJwtBearerAuthentication)

                是否可以修改 Swagger 請求的標頭,以便可以測試具有 [Authorize] 屬性的路由?

                Is it possible to modify the header of the Swagger requests so the routes with the [Authorize] attribute can be tested?

                推薦答案

                我遇到了同樣的問題,并在這篇博文中找到了一個可行的解決方案:http://blog.sluijsveld.com/28/01/2016/CustomSwaggerUIField

                I struggled with the same problem and found a working solution in this blogpost: http://blog.sluijsveld.com/28/01/2016/CustomSwaggerUIField

                歸結為在您的配置選項中添加它

                It comes down to adding this in your configurationoptions

                services.ConfigureSwaggerGen(options =>
                {
                   options.OperationFilter<AuthorizationHeaderParameterOperationFilter>();
                });
                

                以及操作過濾器的代碼

                public class AuthorizationHeaderParameterOperationFilter : IOperationFilter
                {
                   public void Apply(Operation operation, OperationFilterContext context)
                   {
                      var filterPipeline = context.ApiDescription.ActionDescriptor.FilterDescriptors;
                      var isAuthorized = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is AuthorizeFilter);
                      var allowAnonymous = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is IAllowAnonymousFilter);
                
                      if (isAuthorized && !allowAnonymous)
                      {
                          if (operation.Parameters == null)
                             operation.Parameters = new List<IParameter>();
                
                          operation.Parameters.Add(new NonBodyParameter
                          {                    
                             Name = "Authorization",
                             In = "header",
                             Description = "access token",
                             Required = true,
                             Type = "string"
                         });
                      }
                   }
                }
                

                然后你會在你的 swagger 中看到一個額外的 Authorization TextBox,你可以在其中以Bearer {jwttoken}"格式添加你的令牌,并且你應該在你的 swagger 請求中獲得授權.

                Then you will see an extra Authorization TextBox in your swagger where you can add your token in the format 'Bearer {jwttoken}' and you should be authorized in your swagger requests.

                這篇關于在 ASP.NET Core 的 Swagger 中使用 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)
                <tfoot id='6zPfI'></tfoot>

                • <bdo id='6zPfI'></bdo><ul id='6zPfI'></ul>

                    <tbody id='6zPfI'></tbody>
                  • <legend id='6zPfI'><style id='6zPfI'><dir id='6zPfI'><q id='6zPfI'></q></dir></style></legend>
                  • <small id='6zPfI'></small><noframes id='6zPfI'>

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

                          主站蜘蛛池模板: 久久久久久久久久久久一区二区 | 伊人99 | 91精品国产91久久综合桃花 | 国产精品乱码一区二区三区 | 欧美日韩国产一区二区三区 | www.午夜| 蜜臀av日日欢夜夜爽一区 | 成人精品毛片国产亚洲av十九禁 | 日韩久久久久 | 九九亚洲 | 国产欧美日韩精品一区二区三区 | 精品一区二区免费视频 | 国产欧美日韩在线观看 | 欧美日韩精品免费观看 | 国产乱码精品一品二品 | 干一干操一操 | 国产日韩久久 | 国产四区| 久久高清 | 欧美国产日本一区 | 国产精品免费视频一区 | 国产精品美女久久久久久久久久久 | 国产精品一区二区三区在线播放 | 91久久精品视频 | 99国产精品99久久久久久 | 一级爱爱片 | 国产精品一区二区三级 | 国产成在线观看免费视频 | 国产午夜精品福利 | 亚洲欧美一区二区三区1000 | 欧美精品成人一区二区三区四区 | 久久亚洲国产精品 | 日韩欧美一区二区三区免费观看 | 欧美一级免费黄色片 | 91免费视频| 国产精品18久久久久久白浆动漫 | 九九热精品在线 | 久久亚洲一区二区三 | 日日天天 | 亚州精品天堂中文字幕 | 日韩精品一区二区三区在线观看 |