NETSigner 1.0.2
dotnet add package NETSigner --version 1.0.2
NuGet\Install-Package NETSigner -Version 1.0.2
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="NETSigner" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NETSigner --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NETSigner, 1.0.2"
#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.
// Install NETSigner as a Cake Addin #addin nuget:?package=NETSigner&version=1.0.2 // Install NETSigner as a Cake Tool #tool nuget:?package=NETSigner&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NETSigner
提供 API 签名验证功能,遵循 使用摘要签名认证方式调用 API 签名规范
简单使用
asp.netcore
安装
在项目目录下执行下列命令
dotnet add package NETSigner
dotnet add package NETSigner.AspNetCore
代码
///Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddNETSigner();
var app = builder.Build();
app.UseNETSigner();
app.Map("sign", context => context.Response.WriteAsync("> success"));
await app.RunAsync();
高级
自定义 SKGetter
由于在传输过程中 sk 容易暴露,所以需要我们引入了 ak,服务端通过 ak 来指向一个 sk。这样就可以不用暴露 sk
///MySKGetter.cs
public class MySKGetter : ISKGetter
{
public string GetSK(string ak)
{
//访问数据库获取sk并return
return "sk";
};
}
///Program.cs
...
builder.Services.AddSingleton<ISKGetter, MySKGetter>();
builder.Services.AddNETSigner();
...
自定义 NonceRecorder
为了防止请求重放攻击,我们引入了 nonce
///MyNonceRecorder.cs
public class MyNonceRecorder : INonceRecorder
{
private readonly ConcurrentDictionary<string, byte> _cache = new();
public bool Record(string nonce, TimeSpan delay)
{
//加入到缓存,并设置过期时间。(我这里的代码只是示例,具体如何实现加入redis缓存需要自行研究)
return _cache.TryAdd(nonce, 0);
}
}
///Program.cs
...
builder.Services.AddSingleton<INonceRecorder, MyNonceRecorder>();
builder.Services.AddNETSigner();
...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NETSigner:
Package | Downloads |
---|---|
NETSigner.AspNetCore
NETSigner库的AspNetCore扩展,快速集成NETSigner功能 |
GitHub repositories
This package is not used by any popular GitHub repositories.