草庐IT

delete_customer_token

全部标签

c# - .Net Core JwtBearer 身份验证不拒绝过期的 token

我正在生成JWT以用于我的WebApi项目。我将token设置为在一分钟后过期,以便我可以测试它是否在过期日期后拒绝提交token。CreateTokenControllerpublicasyncTaskCreateToken([FromBody]CredentialModelmodel){varuser=await_unitOfWork.UserManager.FindByNameAsync(model.UserName);if(user==null)returnBadRequest();if(Hasher.VerifyHashedPassword(user,user.Passwor

c# - Google OAuth2 服务帐户访问 token 请求提供 'Invalid Request' 响应

我正在尝试通过服务器到服务器方法与我的应用启用的BigQueryAPI进行通信。我已勾选此Googleguide上的所有方框在C#中尽我所能构建我的JWT。我已经对所有必要的内容进行了Base64Url编码。但是,我从google得到的唯一响应是400BadRequest"error":"invalid_request"我已经从这些其他SO问题中确定了以下所有内容:ThesignatureisproperlyencryptedusingRSAandSHA256IamusingPOSTandusingapplication/x-www-form-urlencodedcontenttype

c# - 在 Directory.Delete 之后,Directory.Exists 有时会返回 true 吗?

我的行为很奇怪。我有,Directory.Delete(tempFolder,true);if(Directory.Exists(tempFolder)){}有时Directory.Exists返回true。为什么?可能是资源管理器打开了吗? 最佳答案 Directory.Delete调用WindowsAPI函数RemoveDirectory.记录观察到的行为:TheRemoveDirectoryfunctionmarksadirectoryfordeletiononclose.Therefore,thedirectoryisnot

C# WinForm : Remove or Customize the 'Focus Rectangle' for Buttons 格式

有没有办法禁用或更好地为常规按钮控件绘制您自己的焦点矩形!(那条虚线看起来很像Windows95ish)我注意到控件属性(FORBUTTONS)没有ownerdrawfixed设置(我不知道这是否是用于解决方案的路径,尽管我已经看到它用于自定义其他控件). 最佳答案 要做到这一点比听起来要棘手。毫无疑问,自定义按钮绘制不可覆盖的原因之一。这按预期工作:usingSystem;usingSystem.Drawing;usingSystem.Windows.Forms;usingSystem.Windows.Forms.VisualSt

c# - Linq Getting Customers 按日期分组,然后按类型分组

我正在使用C#中的LINQ生成报告以向客户展示。我想显示没有。每种类型的客户。注册的客户有客人和经理三种类型。我想按客户注册日期分组,然后按客户类型分组。即,如果今天插入了3位客人、4位注册人和2位经理。明天4,5和6分别注册。然后报告应显示当天注册的客户数量。每种类型单独一行。DATETYPEOFCUSTOMERCOUNT31-10-2013GUEST331-10-2013REGISTERED431-10-2013MANAGER230-10-2013GUEST530-10-2013REGISTERED1030-10-2013MANAGER3像这样。varsubquery=fromea

c# - 无法使用 ASP.NET Core 从 JWT token 获取声明

我正在尝试使用ASP.NETCore执行JWT持有者身份验证的非常简单的实现。我从Controller返回的响应有点像这样:varidentity=newClaimsIdentity();identity.AddClaim(newClaim(ClaimTypes.Name,applicationUser.UserName));varjwt=newJwtSecurityToken(_jwtOptions.Issuer,_jwtOptions.Audience,identity.Claims,_jwtOptions.NotBefore,_jwtOptions.Expiration,_jwt

c# - Asp.net 核心 2 - 不记名 token 出现 401 错误

我无法使用Asp.netCore生成的token授权访问protected方法。配置:services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(cfg=>{cfg.RequireHttpsMetadata=false;cfg.SaveToken=true;cfg.Audience=Configuration["Tokens:Issuer"];cfg.ClaimsIssuer=Configuration["Tokens:Issuer"];cfg.TokenValidationParame

c# - 尝试使用 .NET JWT 库生成 token 时出错

我正在尝试使用包System.IdentityModel.Tokens.Jwt来生成token。我在网上找到了一些代码示例,非常简单,但后来我遇到了一个我无法弄清楚的错误。这是我正在使用的代码(为简洁起见略有修改):publicclassTestClass{publicstaticstringGetJwtToken(){vartokenHandler=newJwtSecurityTokenHandler();varinput="anyoldrandomtext";varsecurityKey=newbyte[input.Length*sizeof(char)];Buffer.Block

c# - 为什么我不能将 List<Customer> 作为参数传递给接受 List<object> 的方法?

下面的代码给我这个错误:Cannotconvertfrom'System.Collections.Generic.List'to'System.Collections.Generic.List'.我如何向编译器表明Customer确实继承自对象?或者它只是不对通用集合对象进行继承(发送List会得到相同的错误)。usingSystem.Collections.Generic;usingSystem.Windows;usingSystem.Windows.Documents;namespaceTestControl3423{publicpartialclassWindow2:Window

c# - 验证 Windows 身份 token

我正在尝试开发一个简单的Web服务来使用Windows身份框架对桌面应用程序的用户进行身份验证,目前我正在通过帖子传递WindowsIdentity.GetCurrent().Token生成的token变量(它是加密的和ssl的,考虑到我们域的布局和服务器的配置,Windows身份验证不是一个选项)。我正在将token传递回去并将其转换回IntPtr。我不知道如何验证token以确保它是由特定的ActiveDirectory(或任何与此相关的)生成的。我试图在给定token的情况下创建一个新的WindowsIdentity实例,但这只会导致异常(消息:模拟token无效-无法复制)。如