当前位置:网站首页>. 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 .

边栏推荐
猜你喜欢

SDS understanding in redis

Realization of BFS in C language by storing adjacency matrix of graph
![[punch in - Blue Bridge Cup] day 5 --- lower() small](/img/b5/21f51a7416c72c299cc59192a33b3a.jpg)
[punch in - Blue Bridge Cup] day 5 --- lower() small
![[summary of skimming questions] database questions are summarized by knowledge points (continuous update / simple and medium questions have been completed)](/img/89/fc02ce355c99031623175c9f351790.jpg)
[summary of skimming questions] database questions are summarized by knowledge points (continuous update / simple and medium questions have been completed)
![[punch in - Blue Bridge Cup] day 2 --- format output format, ASCII](/img/b2/0059659867e867a32b8e7cef567c8b.jpg)
[punch in - Blue Bridge Cup] day 2 --- format output format, ASCII

RPC correction

Redis在windows系统中使用

Stc89c52/90c516rd/89c516rd ADC0832 ADC driver code

How do college students make money by programming| My way to make money in College

1148_ Makefile learning_ Targets, variables, and wildcards in makefile
随机推荐
124 articles in total! Motianlun "high availability architecture" dry goods document sharing (including Oracle, mysql, PG)
【模糊神经网络预测】基于模糊神经网络实现水质预测含Matlab源码
将DataBinding整合到Activity/Fragment的一种极简方式
毕业设计EMS办公管理系统(B/S结构)+J2EE+SQLserver8.0
Analysis of similarities and differences of various merged features (Union, merge, append, resolve) in ArcGIS
DRF -- nested serializer (multi table joint query)
[note] on May 28, 2022, data is obtained from the web page and written into the database
[operation] MySQL query on May 24, 2022
DO280私有仓库持久存储与章节实验
Ubuntu20.04 PostgreSQL 14 installation configuration record
(Reprinted) an article will take you to understand the reproducing kernel Hilbert space (RKHS) and various spaces
[operation] write CSV to database on May 28, 2022
Practical debugging skills
共124篇!墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG)
ThingsBoard教程(二三):在规则链中计算二个设备的温度差
2021-07-05
解决navicat连接数据库遇到的问题
UML diagrams and list collections
专升本语文资源整理
绿色新动力,算力“零”负担——JASMINER X4系列火爆热销中