MongoDbTokenManager 4.0.0
dotnet add package MongoDbTokenManager --version 4.0.0
NuGet\Install-Package MongoDbTokenManager -Version 4.0.0
<PackageReference Include="MongoDbTokenManager" Version="4.0.0" />
paket add MongoDbTokenManager --version 4.0.0
#r "nuget: MongoDbTokenManager, 4.0.0"
// Install MongoDbTokenManager as a Cake Addin #addin nuget:?package=MongoDbTokenManager&version=4.0.0 // Install MongoDbTokenManager as a Cake Tool #tool nuget:?package=MongoDbTokenManager&version=4.0.0
MongoDbTokenManager
MongoDbTokenManager is an open-source C# class library that create One Time Tokens that can be used in your C# projects. The tokens are stored in a MongoDb database that you configure using the package MongoDbService
Features
- Genration of Tokens that can be used for SMS or Email ownership verification use cases
- Uses MongoDB so is very fast and distributed, so can be used for web applications that need to be scaled out i.e. one instance of the service could Generate while another can Verify
Contributing
We welcome contributions! If you find a bug, have an idea for improvement, please submit an issue or a pull request on GitHub.
Getting Started
NuGet Package
To include MongoDbTokenManager in your project, install the NuGet package:
dotnet add package MongoDbTokenManager
After the above is done, you can just Dependency inject the MongoDbTokenService
in your C# class.
For example:
Lets say your had a class called VerificationService
as follows:
using MongoDbTokenManager;
using MongoDbTokenManager.Database;
namespace YourNameSpace
{
public sealed class VerificationService
{
private readonly MongoDbTokenService _mongoDbTokenService;
public VerificationService(
MongoDbTokenService mongoDbTokenService
)
{
_mongoDbTokenService = mongoDbTokenService;
}
public async Task<string> Generate(string id)
{
return await _mongoDbTokenService.Generate(
logId: "Example",
id: id,
validityInSeconds: 120,
numberOfDigits: 8);
}
public async Task<bool> Verify(string id, string OTT) // id along with the generated One Time Token
{
return await _mongoDbTokenService.ConsumeAndValidate(id, OTT); // You only get one chance, if you want more use `Consume` and `Validate` separately.
}
}
}
If you Verify
the string
generated by Generate
for id
within 120 seconds, it will return true, else false.
GitHub Repository
Visit our GitHub repository for the latest updates, documentation, and community contributions. https://github.com/prmeyn/MongoDbTokenManager
License
This project is licensed under the GNU GENERAL PUBLIC LICENSE.
Happy coding! 🚀🌐📚
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- MongoDbService (>= 4.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MongoDbTokenManager:
Package | Downloads |
---|---|
EmailSwitch
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.