NetPro.Authentication
6.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package NetPro.Authentication --version 6.0.3
NuGet\Install-Package NetPro.Authentication -Version 6.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetPro.Authentication" Version="6.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetPro.Authentication" Version="6.0.3" />
<PackageReference Include="NetPro.Authentication" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetPro.Authentication --version 6.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetPro.Authentication, 6.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetPro.Authentication@6.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetPro.Authentication&version=6.0.3
#tool nuget:?package=NetPro.Authentication&version=6.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Authentication使用
对Microsoft.AspNetCore.Authentication认证组件的封装,简化使用
使用
appsetting.json
"AuthenticationOption": {
"Enabled": true,
"Secret": "6666666666666666", //最少配置16位
"Issuer": "NetPro.com",
"AccessTokenExpired": 6, //单位小时
"RefreshTokenExpired": 168 //单位小时
}
启用服务
public void ConfigureServices(IServiceCollection services)
{
services.AddNetProAuthentication(configuration);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseNetProAuthentication();
}
如增加了以下环境变量配置,可省略以上初始化代码,内部将自动执行以上初始化
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "NetPro.Startup"
使用说明
[Authorize]
/// <summary>
/// 方法或者类加[Authorize]特性,此接口或者此控制器将启用JWT认证才可访问,具体参考示例
/// </summary>
public void Method()
[AllowAnonymous]
/// <summary>
/// 方法或者类加[Authorize]特性,此接口或者此控制器将强制匿名访问,具体参考示例
/// </summary>
public void Method()
备注
如认证接口数量大于匿名接口数量,建议接口全局默认认证访问,可省去频繁[Authorize]
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers().RequireAuthorization();
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.AspNetCore.Authentication (>= 2.2.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.IdentityModel.Tokens (>= 6.15.0)
- NetPro.Core (>= 6.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NetPro.Authentication:
| Package | Downloads |
|---|---|
|
NetPro.Web.Core
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 6.0.16 | 394 | 7/24/2023 | |
| 6.0.15 | 597 | 7/19/2022 | |
| 6.0.14 | 604 | 7/10/2022 | |
| 6.0.13 | 571 | 6/15/2022 | |
| 6.0.12 | 587 | 6/15/2022 | |
| 6.0.11 | 580 | 6/15/2022 | |
| 6.0.10 | 600 | 6/11/2022 | |
| 6.0.9 | 595 | 6/8/2022 | |
| 6.0.8 | 576 | 5/26/2022 | |
| 6.0.8-beta.3 | 246 | 5/24/2022 | |
| 6.0.8-beta.2 | 238 | 5/24/2022 | |
| 6.0.7 | 592 | 5/18/2022 | |
| 6.0.6 | 613 | 4/28/2022 | |
| 6.0.5 | 582 | 3/30/2022 | |
| 6.0.5-beta.20 | 238 | 4/27/2022 | |
| 6.0.5-beta.19 | 252 | 4/25/2022 | |
| 6.0.5-beta.18 | 250 | 4/22/2022 | |
| 6.0.5-beta.17 | 261 | 4/16/2022 | |
| 6.0.5-beta.16 | 265 | 4/8/2022 | |
| 6.0.5-beta.15 | 250 | 4/8/2022 | |
| 6.0.5-beta.14 | 270 | 4/7/2022 | |
| 6.0.5-beta.13 | 261 | 4/7/2022 | |
| 6.0.5-beta.12 | 259 | 4/6/2022 | |
| 6.0.5-beta.11 | 258 | 4/6/2022 | |
| 6.0.5-beta.10 | 261 | 3/31/2022 | |
| 6.0.5-beta.9 | 278 | 3/26/2022 | |
| 6.0.5-beta.8 | 266 | 3/22/2022 | |
| 6.0.5-beta.7 | 248 | 3/21/2022 | |
| 6.0.5-beta.6 | 257 | 3/14/2022 | |
| 6.0.5-beta.5 | 258 | 3/2/2022 | |
| 6.0.5-beta.4 | 257 | 2/22/2022 | |
| 6.0.5-beta.3 | 264 | 2/18/2022 | |
| 6.0.5-beta.2 | 255 | 2/18/2022 | |
| 6.0.5-beta.1 | 262 | 2/16/2022 | |
| 6.0.4 | 604 | 2/10/2022 | |
| 6.0.3 | 581 | 2/9/2022 | |
| 6.0.3-beta.9 | 263 | 2/10/2022 | |
| 6.0.3-beta.7 | 277 | 1/27/2022 | |
| 6.0.3-beta.6 | 280 | 1/19/2022 | |
| 6.0.3-beta.5 | 265 | 1/17/2022 | |
| 6.0.3-beta.4 | 267 | 1/16/2022 | |
| 6.0.3-beta.3 | 266 | 1/14/2022 | |
| 6.0.3-beta.2 | 277 | 1/13/2022 | |
| 6.0.3-beta.1 | 293 | 1/11/2022 | |
| 6.0.2 | 522 | 1/6/2022 | |
| 6.0.1 | 1,164 | 12/3/2021 | |
| 3.1.11 | 733 | 11/19/2021 | |
| 3.1.10 | 2,004 | 7/29/2021 | |
| 3.1.9 | 1,787 | 7/1/2021 | |
| 3.1.8 | 1,895 | 12/15/2020 | |
| 3.1.6 | 3,230 | 9/16/2020 |