MongoDbTokenManager 3.0.1

dotnet add package MongoDbTokenManager --version 3.0.1
NuGet\Install-Package MongoDbTokenManager -Version 3.0.1
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="MongoDbTokenManager" Version="3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MongoDbTokenManager --version 3.0.1
#r "nuget: MongoDbTokenManager, 3.0.1"
#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 MongoDbTokenManager as a Cake Addin
#addin nuget:?package=MongoDbTokenManager&version=3.0.1

// Install MongoDbTokenManager as a Cake Tool
#tool nuget:?package=MongoDbTokenManager&version=3.0.1

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 0 7/7/2024
3.0.0 0 7/7/2024
2.1.0 34 7/5/2024
2.0.0 71 6/23/2024
1.0.0 67 6/23/2024