当前位置:网站首页>. Net 7 JWT configuration is too convenient!
. Net 7 JWT configuration is too convenient!
2022-06-30 03:48:00 【Dotnet cross platform】
Microsoft announces .NET 7 preview5 There are some big improvements , Include JWT Simplified and automated authentication configuration .
I installed. preview 5 Tried a new JWT Identity configuration . If you want to update an existing project to .Net 7 preview 5, Here is a quick update command .
Update all Microsoft.AspNetCore.* package references to 7.0.0-preview.5.*.
Update all Microsoft.Extensions.* package references to 7.0.0-preview.5.*.
.NET 7 Previous JWT Authentication configuration
Microsoft says it has received feedback , stay ASP.NET Core Configuration in the project JWT, It's writing API Is one of the hardest parts . It takes many steps , This includes adding middleware and configuring services during startup .
.Net The team knows JWT Configure in protection API The importance of , That's why they have improved and simplified the ASP.NET Core Configuration in the project JWT The process of Authentication .
A simplified JWT To configure
WebApplicationBuilder Added a new Authentication attribute , You can then call AddJwtBearer() Method , as follows
var builder = WebApplication.CreateBuilder(args);
builder.Authentication.AddJwtBearer();
var app = builder.Build();
Use this new property to set JWT Authentication automatically adds the required middleware , No additional code is required .
most important of all , Now you can directly appsettings.json To configure JWT, You can easily configure multiple environments .
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Authentication": {
"DefaultScheme" : "JwtBearer",
"Schemes": {
"JwtBearer": {
"Audiences": [ "http://localhost:5000",
"https://localhost:5001" ],
"ClaimsIssuer": "user-jwt-here"
}
}
}
}
Above is .NET 7 preview 5 Simplified in JWT To configure , This is very convenient , This improvement can really help developers save time on configuring projects .
END
Made a .NET The learning website , Covering distributed systems , Data structure and algorithm , Design patterns , operating system , Computer network, etc , And job recommendation and interview experience sharing , Welcome to flirt .
边栏推荐
- UML图与List集合
- MySQL performance optimization (6): read write separation
- 【笔记】AB测试和方差分析
- MySQL performance optimization (5): principle and implementation of master-slave synchronization
- Is the largest layoff and salary cut on the internet coming?
- Semantic segmentation resources
- RPC correction
- 使用IDEAL连接数据库,运行出来了 结果显示一些警告,这部分怎么处理
- [ten minutes] manim installation 2022
- [0x0] open questions left by the principal
猜你喜欢
[note] May 23, 2022 MySQL
(Reprinted) an article will take you to understand the reproducing kernel Hilbert space (RKHS) and various spaces
【论文阅读|深读】Role2Vec:Role-Based Graph Embeddings
MySQL performance optimization (6): read write separation
Redis中的Hash设计和节省内存数据结构设计
专升本语文资源整理
第2章 控制结构和函数(编程题)
Mysql性能优化(5):主从同步原理与实现
How to view Tencent's 2022 school recruitment salary, the total contract of cabbage is 40W?
[ten minutes] manim installation 2022
随机推荐
Local, locallow and roaming in the appdata folder
【笔记】2022.5.23 MySQL
Redis is used in Windows system
[operation] getting started with MySQL on May 23, 2022
A minimalist way to integrate databinding into activity/fragment
第2章 控制结构和函数(编程题)
深入浅出掌握grpc通信框架
Implementation of property management system with ssm+ wechat applet
华为云原生——数据开发与DataFactory
The next change direction of database - cloud native database
4-4 beauty ranking (10 points)
Geometric objects in shapely
专升本语文资源整理
绿色新动力,算力“零”负担——JASMINER X4系列火爆热销中
1151_ Makefile learning_ Static matching pattern rules in makefile
TiDB 6.0:讓 TSO 更高效丨TiDB Book Rush
AppData文件夹下Local,Locallow和Roaming
关于智能视觉组上的机械臂
Pytorch Profiler+ Tensorboard + VS Code
【常见问题】页面跨域和接口跨域