.net core 3.1 WepApi 前后分离身份验证及webapi调试demo ,jwt+swagger

上传者: yangyueweiqing | 上传时间: 2021-03-22 11:25:10 | 文件大小: 1.2MB | 文件类型: RAR
.netcore3.1添加swagger及JWT Authorize 验证
JWT 的优缺点
相比于传统的 cookie-session 认证机制,优点有:

更适用分布式和水平扩展
在cookie-session方案中,cookie内仅包含一个session标识符,而诸如用户信息、授权列表等都保存在服务端的session中。如果把session中的认证信息都保存在JWT中,在服务端就没有session存在的必要了。当服务端水平扩展的时候,就不用处理session复制(session replication)/ session黏连(sticky session)或是引入外部session存储了。

适用于多客户端(特别是移动端)的前后端解决方案
移动端使用的往往不是网页技术,使用Cookie验证并不是一个好主意,因为你得和Cookie容器打交道,而使用Bearer验证则简单的多。

无状态化
JWT 是无状态化的,更适用于 RESTful 风格的接口验证。

它的缺点也很明显:

更多的空间占用
JWT 由于Payload里面包含了附件信息,占用空间往往比SESSION ID大,在HTTP传输中会造成性能影响。所以在设计时候需要注意不要在JWT中存储太多的claim,以避免发生巨大的,过度膨胀的请求。

无法作废已颁布的令牌
所有的认证信息都在JWT中,由于在服务端没有状态,即使你知道了某个JWT被盗取了,你也没有办法将其作废。在JWT过期之前(你绝对应该设置过期时间),你无能为力。

文件下载

资源详情

[{"title":"( 81 个子文件 1.2MB ) .net core 3.1 WepApi 前后分离身份验证及webapi调试demo ,jwt+swagger","children":[{"title":"JwtSwagger.Demo","children":[{"title":"Program.cs <span style='color:#111;'> 723B </span>","children":null,"spread":false},{"title":"appsettings.Development.json <span style='color:#111;'> 162B </span>","children":null,"spread":false},{"title":"Controllers","children":[{"title":"WeatherForecastController.cs <span style='color:#111;'> 1.22KB </span>","children":null,"spread":false},{"title":"UserController.cs <span style='color:#111;'> 3.27KB </span>","children":null,"spread":false}],"spread":true},{"title":"appsettings.json <span style='color:#111;'> 315B </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"JwtSwagger.Demo.csproj.nuget.g.props <span style='color:#111;'> 1.14KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.csproj.nuget.dgspec.json <span style='color:#111;'> 2.81KB </span>","children":null,"spread":false},{"title":"Business.Api.csproj.nuget.dgspec.json <span style='color:#111;'> 2.79KB </span>","children":null,"spread":false},{"title":"Business.Api.csproj.nuget.g.targets <span style='color:#111;'> 294B </span>","children":null,"spread":false},{"title":"Business.Api.csproj.nuget.g.props <span style='color:#111;'> 1.14KB </span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"netcoreapp3.1","children":[{"title":"Business.Api.MvcApplicationPartsAssemblyInfo.cache <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.AssemblyInfoInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.assets.cache <span style='color:#111;'> 8.32KB </span>","children":null,"spread":false},{"title":"Business.Api.AssemblyInfo.cs <span style='color:#111;'> 1019B </span>","children":null,"spread":false},{"title":"Business.Api.csproj.FileListAbsolute.txt <span style='color:#111;'> 3.88KB </span>","children":null,"spread":false},{"title":"Business.Api.RazorTargetAssemblyInfo.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.MvcApplicationPartsAssemblyInfo.cs <span style='color:#111;'> 635B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.csproj.FileListAbsolute.txt <span style='color:#111;'> 3.34KB </span>","children":null,"spread":false},{"title":"Business.Api.pdb <span style='color:#111;'> 3.94KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.RazorTargetAssemblyInfo.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"Business.Api.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.exe <span style='color:#111;'> 167.50KB </span>","children":null,"spread":false},{"title":"Business.Api.AssemblyInfoInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.AssemblyInfo.cs <span style='color:#111;'> 1.00KB </span>","children":null,"spread":false},{"title":"Business.Api.csprojAssemblyReference.cache <span style='color:#111;'> 424B </span>","children":null,"spread":false},{"title":"Business.Api.assets.cache <span style='color:#111;'> 8.32KB </span>","children":null,"spread":false},{"title":"Business.Api.genruntimeconfig.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"Business.Api.dll <span style='color:#111;'> 19.50KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.pdb <span style='color:#111;'> 3.92KB </span>","children":null,"spread":false},{"title":"Business.Api.MvcApplicationPartsAssemblyInfo.cs <span style='color:#111;'> 635B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.dll <span style='color:#111;'> 19.50KB </span>","children":null,"spread":false},{"title":"Business.Api.csproj.CopyComplete <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"staticwebassets","children":[{"title":"Business.Api.StaticWebAssets.xml <span style='color:#111;'> 36B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.StaticWebAssets.Manifest.cache <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Business.Api.StaticWebAssets.Manifest.cache <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.StaticWebAssets.xml <span style='color:#111;'> 36B </span>","children":null,"spread":false}],"spread":false},{"title":"JwtSwagger.Demo.MvcApplicationPartsAssemblyInfo.cache <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.csproj.CopyComplete <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Business.Api.exe <span style='color:#111;'> 167.50KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.genruntimeconfig.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"JwtSwagger.Demo.csproj.nuget.g.targets <span style='color:#111;'> 294B </span>","children":null,"spread":false},{"title":"project.assets.json <span style='color:#111;'> 25.22KB </span>","children":null,"spread":false},{"title":"project.nuget.cache <span style='color:#111;'> 2.22KB </span>","children":null,"spread":false}],"spread":true},{"title":"bin","children":[{"title":"Debug","children":[{"title":"netcoreapp3.1","children":[{"title":"Business.Api.runtimeconfig.json <span style='color:#111;'> 224B </span>","children":null,"spread":false},{"title":"runtimes","children":[{"title":"unix","children":[{"title":"lib","children":[{"title":"netcoreapp2.1","children":null,"spread":false},{"title":"netcoreapp2.0","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"win","children":[{"title":"lib","children":[{"title":"netstandard2.0","children":null,"spread":false},{"title":"netcoreapp2.1","children":null,"spread":false},{"title":"netcoreapp2.0","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"win-x86","children":[{"title":"native","children":null,"spread":false}],"spread":true},{"title":"win-x64","children":[{"title":"native","children":null,"spread":false}],"spread":false},{"title":"win-arm64","children":[{"title":"native","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"ko","children":null,"spread":false},{"title":"fr","children":null,"spread":false},{"title":"zh-Hans","children":null,"spread":false},{"title":"tr","children":null,"spread":false},{"title":"appsettings.Development.json <span style='color:#111;'> 162B </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.runtimeconfig.json <span style='color:#111;'> 224B </span>","children":null,"spread":false},{"title":"Swashbuckle.AspNetCore.SwaggerUI.dll <span style='color:#111;'> 1.73MB </span>","children":null,"spread":false},{"title":"appsettings.json <span style='color:#111;'> 315B </span>","children":null,"spread":false},{"title":"pl","children":null,"spread":false},{"title":"Business.Api.pdb <span style='color:#111;'> 3.94KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Authentication.JwtBearer.dll <span style='color:#111;'> 36.38KB </span>","children":null,"spread":false},{"title":"Business.Api.deps.json <span style='color:#111;'> 115.49KB </span>","children":null,"spread":false},{"title":"de","children":null,"spread":false},{"title":"zh-Hant","children":null,"spread":false},{"title":"Microsoft.IdentityModel.JsonWebTokens.dll <span style='color:#111;'> 64.55KB </span>","children":null,"spread":false},{"title":"ru","children":null,"spread":false},{"title":"Swashbuckle.AspNetCore.SwaggerGen.dll <span style='color:#111;'> 69.50KB </span>","children":null,"spread":false},{"title":"pt-BR","children":null,"spread":false},{"title":"it","children":null,"spread":false},{"title":"JwtSwagger.Demo.exe <span style='color:#111;'> 167.50KB </span>","children":null,"spread":false},{"title":"Business.Api.runtimeconfig.dev.json <span style='color:#111;'> 234B </span>","children":null,"spread":false},{"title":"Business.Api.dll <span style='color:#111;'> 19.50KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.pdb <span style='color:#111;'> 3.92KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.runtimeconfig.dev.json <span style='color:#111;'> 234B </span>","children":null,"spread":false},{"title":"Newtonsoft.Json.dll <span style='color:#111;'> 641.00KB </span>","children":null,"spread":false},{"title":"System.IdentityModel.Tokens.Jwt.dll <span style='color:#111;'> 87.54KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.dll <span style='color:#111;'> 19.50KB </span>","children":null,"spread":false},{"title":"JwtSwagger.Demo.deps.json <span style='color:#111;'> 115.50KB </span>","children":null,"spread":false},{"title":"Microsoft.IdentityModel.Protocols.OpenIdConnect.dll <span style='color:#111;'> 106.54KB </span>","children":null,"spread":false},{"title":"IdentityModel.dll <span style='color:#111;'> 132.39KB </span>","children":null,"spread":false},{"title":"Microsoft.OpenApi.dll <span style='color:#111;'> 165.87KB </span>","children":null,"spread":false},{"title":"ja","children":null,"spread":false},{"title":"Swashbuckle.AspNetCore.Swagger.dll <span style='color:#111;'> 11.50KB </span>","children":null,"spread":false},{"title":"Microsoft.IdentityModel.Protocols.dll <span style='color:#111;'> 36.54KB </span>","children":null,"spread":false},{"title":"Properties","children":[{"title":"launchSettings.json <span style='color:#111;'> 809B </span>","children":null,"spread":false}],"spread":false},{"title":"es","children":null,"spread":false},{"title":"Microsoft.IdentityModel.Logging.dll <span style='color:#111;'> 31.54KB </span>","children":null,"spread":false},{"title":"ApiDocument.xml <span style='color:#111;'> 1.27KB </span>","children":null,"spread":false},{"title":"Business.Api.exe <span style='color:#111;'> 167.50KB </span>","children":null,"spread":false},{"title":"cs","children":null,"spread":false},{"title":"Microsoft.IdentityModel.Tokens.dll <span style='color:#111;'> 160.74KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true},{"title":"WeatherForecast.cs <span style='color:#111;'> 311B </span>","children":null,"spread":false},{"title":".vs","children":[{"title":"Business.Api","children":[{"title":"v16","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"JwtSwagger.Demo.csproj <span style='color:#111;'> 970B </span>","children":null,"spread":false},{"title":"Startup.cs <span style='color:#111;'> 5.62KB </span>","children":null,"spread":false},{"title":"Properties","children":[{"title":"launchSettings.json <span style='color:#111;'> 809B </span>","children":null,"spread":false}],"spread":true},{"title":"ApiDocument.xml <span style='color:#111;'> 1.27KB </span>","children":null,"spread":false},{"title":"Models","children":[{"title":"Account.cs <span style='color:#111;'> 552B </span>","children":null,"spread":false},{"title":"JwtSettings.cs <span style='color:#111;'> 644B </span>","children":null,"spread":false}],"spread":true},{"title":"JwtSwagger.Demo.csproj.user <span style='color:#111;'> 941B </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

  • 大好河山可骑驴 :
    蛮贵的,还没看内容
    2021-03-16

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明