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

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

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

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

      .NetCore JwtBearerAuthentication 不拒絕過(guò)期令牌

      .NetCore JwtBearerAuthentication not rejecting expired tokens(.NetCore JwtBearerAuthentication 不拒絕過(guò)期令牌)

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

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

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

                <legend id='mgUjd'><style id='mgUjd'><dir id='mgUjd'><q id='mgUjd'></q></dir></style></legend>
                  <tbody id='mgUjd'></tbody>

                本文介紹了.NetCore JwtBearerAuthentication 不拒絕過(guò)期令牌的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                限時(shí)送ChatGPT賬號(hào)..

                我正在生成用于我的 WebApi 項(xiàng)目的 JWT.我將令牌設(shè)置為在一分鐘內(nèi)過(guò)期,以便我可以測(cè)試它在過(guò)期日期之后提交時(shí)是否拒絕令牌.

                I am generating JWT's to use with my WebApi project. I'm set the token to expire in one minute so that I can test if it rejects the token when submitted after the expiration date.

                創(chuàng)建令牌控制器

                public async Task<IActionResult> CreateToken([FromBody] CredentialModel model)
                {
                    var user = await _unitOfWork.UserManager.FindByNameAsync(model.UserName);
                
                    if (user == null) return BadRequest();
                    if (Hasher.VerifyHashedPassword(user, user.PasswordHash, model.Password) !=
                        PasswordVerificationResult.Success) return BadRequest();
                
                    var userClaims = await UserManager.GetClaimsAsync(user);
                
                    var claims = new[]
                    {
                        new Claim(JwtRegisteredClaimNames.Sub, user.UserName),
                        new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
                        new Claim(JwtRegisteredClaimNames.Iat, DateTime.UtcNow.ToString()),
                        new Claim(JwtRegisteredClaimNames.GivenName, user.FirstName), 
                        new Claim(JwtRegisteredClaimNames.FamilyName, user.LastName),
                        new Claim(JwtRegisteredClaimNames.Email, user.Email)
                    }
                    .Union(userClaims);
                
                    var cert = new Certificate(Configuration["Tokens:Certificate"]);
                    var token = new JwtSecurityToken(
                        issuer: Configuration["Tokens:Issuer"],
                        audience: Configuration["Tokens:Audience"],
                        claims: claims,
                        expires: DateTime.UtcNow.AddMinutes(1),
                        signingCredentials: cert.Signature
                    );
                
                    return Ok(new
                    {
                        token = new JwtSecurityTokenHandler().WriteToken(token),
                        expiration = token.ValidTo
                    });
                }
                

                令牌認(rèn)證 - 啟動(dòng)類

                app.UseJwtBearerAuthentication(new JwtBearerOptions()
                {
                    AutomaticAuthenticate = true,
                    AutomaticChallenge = true,
                    TokenValidationParameters = new TokenValidationParameters()
                    {
                        ValidIssuer = Configuration["Tokens:Issuer"],
                        ValidAudience = Configuration["Tokens:Audience"],
                        ValidateIssuerSigningKey = true,
                        IssuerSigningKey = new Certificate(Configuration["Tokens:Certificate"]).SecurityKey,
                        ValidateLifetime = true
                    },
                });
                

                雖然我設(shè)置了 validateLifetime = true,但兩分鐘后令牌不會(huì)被拒絕.它將繼續(xù)接受令牌.是否有我不知道的最短到期時(shí)間或我的設(shè)置有誤?

                Although I am setting validateLifetime = true the tokes are not rejected two minutes later. It will keep accepting the token. Is there a minimum expiration time that I am not aware of or is my setup wrong?

                推薦答案

                我偶然發(fā)現(xiàn)了答案 這里如果有人感興趣的話.ClockSkew 的默認(rèn)值為 5 分鐘.

                I stumbled over the answer here if anyone is interested. Default value for ClockSkew is 5 minutes.

                app.UseJwtBearerAuthentication(new JwtBearerOptions()
                {
                    AutomaticAuthenticate = true,
                    AutomaticChallenge = true,
                    TokenValidationParameters = new TokenValidationParameters()
                    {
                        ValidIssuer = Configuration["Tokens:Issuer"],
                        ValidAudience = Configuration["Tokens:Audience"],
                        ValidateIssuerSigningKey = true,
                        IssuerSigningKey = new Certificate(certPath: Configuration["Tokens:Certificate"], isValid: false).SecurityKey,
                        ValidateLifetime = true,
                        ValidateIssuer = true,
                        ValidateAudience = true,
                        ClockSkew = TimeSpan.Zero
                    },
                });
                

                這篇關(guān)于.NetCore JwtBearerAuthentication 不拒絕過(guò)期令牌的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測(cè)有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運(yùn)行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時(shí)刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時(shí)突出顯示行)
                Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)

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

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

                      <bdo id='9AJxk'></bdo><ul id='9AJxk'></ul>
                        <tbody id='9AJxk'></tbody>

                        <legend id='9AJxk'><style id='9AJxk'><dir id='9AJxk'><q id='9AJxk'></q></dir></style></legend>

                      • <tfoot id='9AJxk'></tfoot>

                        • 主站蜘蛛池模板: 亚洲福利一区二区 | 欧美精品片 | 久久久久久久久久久久一区二区 | 国产成人啪免费观看软件 | 免费观看一级特黄欧美大片 | 艹逼网| 亚洲精品专区 | 国产亚洲第一页 | 最新中文字幕第一页视频 | 国产精品视频久久 | 日韩中文字幕一区二区三区 | 久久福利 | 日本中文字幕在线观看 | 亚洲一卡二卡 | www.99re| 欧美日韩在线精品 | 能看的av网站 | 欧美黄色一区 | 中文字幕一区在线 | av片在线观看网站 | 色综合色综合 | 成人久久久 | 美国一级黄色片 | 日韩午夜网站 | 男人视频网站 | 日韩在线综合 | 在线91| 中文字幕在线三区 | 香蕉久久av | 日韩成人在线观看 | 嫩草网| 91影院在线观看 | 亚洲成在线观看 | 国产精品日韩欧美 | 欧美不卡网站 | 国产欧美精品一区 | 日本高清中文字幕 | 久久亚洲美女 | 超碰婷婷 | 成人精品免费视频 | 福利视频网址 |