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

<tfoot id='6tZro'></tfoot><legend id='6tZro'><style id='6tZro'><dir id='6tZro'><q id='6tZro'></q></dir></style></legend>

    <small id='6tZro'></small><noframes id='6tZro'>

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

    1. 如何在 .net 核心中記錄授權(quán)嘗試

      How do I log authorization attempts in .net core(如何在 .net 核心中記錄授權(quán)嘗試)

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

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

              • 本文介紹了如何在 .net 核心中記錄授權(quán)嘗試的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時送ChatGPT賬號..

                當(dāng)我嘗試訪問授權(quán)屬性下的方法時,我正在嘗試寫入日志.基本上,我想記錄一個人是否使用了無效令牌或過期令牌.我正在使用 JWT 的基本身份驗證

                I'm trying to write to a log when I person tries to access a method under an Authorize Attribute. Basically, I want to log if a person uses an invalid token or an expired token. I'm using basic Authentication for JWT

                services.AddAuthentication(o =>
                {
                    o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                    o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                }).AddJwtBearer(cfg =>
                    {
                        cfg.RequireHttpsMetadata = false;
                        cfg.SaveToken = true;
                
                        cfg.TokenValidationParameters = new TokenValidationParameters()
                        {
                            ValidAudience = jwtAudience,
                            ValidIssuer = jwtIssuer,
                            IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSecurityKey))
                        };
                
                    });
                

                有沒有辦法我可以在授權(quán)檢查中添加一段代碼,以記錄授權(quán)嘗試是否有效以及為什么無效?

                Is there a way I can add a piece of code to the authorization check that logs if a authorization attempt was valid and why it wasn't?

                推薦答案

                您可以訪問 JwtBearerEvents 對象,該對象定義了在處理不記名令牌時引發(fā)的許多事件.

                You have access to the JwtBearerEvents object, which defines a number of events that are raised as the bearer token is processed.

                驗證失敗
                如果在請求處理期間拋出異常,則調(diào)用.除非被抑制,否則異常將在此事件之后重新拋出.

                OnAuthenticationFailed
                Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.

                挑戰(zhàn)在將質(zhì)詢發(fā)送回調(diào)用方之前調(diào)用.

                OnChallenge Invoked before a challenge is sent back to the caller.

                OnMessageReceived
                在第一次收到協(xié)議消息時調(diào)用.

                OnMessageReceived
                Invoked when a protocol message is first received.

                OnTokenValidated
                在安全令牌通過驗證并生成 ClaimsIdentity 后調(diào)用.

                OnTokenValidated
                Invoked after the security token has passed validation and a ClaimsIdentity has been generated.

                https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents?view=aspnetcore-2.0

                在AddJwtBearer初始化配置時,添加你想訂閱的事件,

                When initialising the configuration at AddJwtBearer, add the events you'd like to subscribe to,

                .AddJwtBearer(o =>
                {
                    o.Events = new JwtBearerEvents()
                    {
                        OnAuthenticationFailed = c =>
                        {
                            // do some logging or whatever...
                        }
                
                    };
                });
                

                查看源代碼以了解何時可能引發(fā)事件,

                Have a look at the source to see when events might be raised,

                https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs

                這篇關(guān)于如何在 .net 核心中記錄授權(quán)嘗試的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                  <tbody id='LBAiC'></tbody>

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

                  <bdo id='LBAiC'></bdo><ul id='LBAiC'></ul>
                  1. <legend id='LBAiC'><style id='LBAiC'><dir id='LBAiC'><q id='LBAiC'></q></dir></style></legend>

                      1. <tfoot id='LBAiC'></tfoot>

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

                          主站蜘蛛池模板: 999www视频免费观看 | 中文字幕一二三区 | 天天干干 | 免费视频二区 | 欧美多人在线 | 成年人黄色小视频 | 欧美国产视频 | 国产欧美日韩精品一区二区三区 | 亚洲成人精品 | 亚洲精品日日夜夜 | 国产成人精品网站 | 精品国产91久久久久久 | 精品久久久久久亚洲精品 | 欧美一区二区三区四区五区无卡码 | 97影院2| 99视频在线播放 | 电影午夜精品一区二区三区 | 99视频免费在线观看 | 欧美激情一区二区 | 激情三区 | 亚洲黄色高清视频 | 超碰激情 | 欧美在线一区二区三区 | 亚洲欧美中文日韩在线v日本 | 日本三级在线网站 | 成人黄色a | 秋霞在线一区二区 | 在线免费中文字幕 | 日韩精品一区二区三区免费观看 | 国产精品一区二区福利视频 | 一区二区手机在线 | 中文字幕乱码亚洲精品一区 | 国产一区二区在线免费观看 | 精品免费国产 | 国产欧美日韩一区二区三区在线 | 久久99精品久久久久久 | 美日韩免费视频 | 精品久久一区 | 四虎海外| 国产高清视频 | 91福利网址 |