asp.net-core - Authorization not working, It does not forbidden users to access my actions in asp.net core
问题描述
In start up
ConfigureServices function I add this
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(jwtBearerOptions =>
{
jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuerSigningKey = true,
ValidateIssuer = false,
ValidateAudience = false
};
});
then in Configure function I added this
app.UseAuthentication();
app.UseAuthorization();
and I added this line to my API
[Authorize]
but it give user to allow that function, what is my mistake? which part of auth I forget to add my code?
解决方案
推荐阅读
- r - 使用 R googlesheets 超时对用户进行身份验证
- linker-errors - 为什么我不能 PRELOAD 我自己的 libc.so.6 来运行动态可执行文件
- amazon-web-services - 查找给定资源的 Cloudwatch 日志组
- c - STM32:无法退出UART中断的中断处理程序
- java - OpenCV - Java:VideoCapture 读取帧与 USB 摄像头挂起
- kotlin - 如何使用泛型反序列化 Jackson 容器
- android - 从获取意图中添加项目以再次发布在购物车购物 Android 等不同活动上
- angular - 剑道角度用户界面:剑道网格单元选择/突出显示
- python - Python3防止嵌套列表并显示列表中值的位置/索引
- javascript - 计时器事件完成触发后,Div\label\Span 消失