About ย | ย Features ย | ย Technologies ย | ย Requirements ย | ย Starting
The Securelib is a simple C# library, developed with .Net 8 but fully compatible with .Net 6+, that provides you with the following features:
โ๏ธ Aes Encryption/Decryption
โ๏ธ RSA Encryption/Decryption
โ๏ธ JWT Authentication tokens
โ๏ธ TOTP Code
The following tools were used in this project:
Before starting ๐, you need to have Git, DotNet 8 SDK and Docker installed.
# Clone this project
$ git clone https://github.com/devgalop/lrn.securelib
# Access
$ cd {ROOT_FOLDER}
#Create own solution
dotnet new sln -n lrn.devgalop.securelib
# Assign projects to solution
dotnet sln add ./lrn.devgalop.securelib.Core/lrn.devgalop.securelib.Core.csproj
dotnet sln add ./lrn.devgalop.securelib.Infrastructure/lrn.devgalop.securelib.Infrastructure.csproj
dotnet sln add ./lrn.devgalop.securelib.Webapi/lrn.devgalop.securelib.Webapi.csproj
dotnet sln add ./lrn.devgalop.securelib.Tests/lrn.devgalop.securelib.Tests.csproj
# Install dependencies
$ dotnet restore ./lrn.devgalop.securelib.WebApi/lrn.devgalop.securelib.WebApi.csproj
# Build docker image
$ docker build -t securelib:development .
# Run docker-compose
$ docker-compose -f ./Docker/docker-compose-development.yml up -d
# The server will initialize in the <http://localhost:5200>
If you need to use any of the libraries in the project, follow the steps below:
- Select the folder(s) you want to use and import them into your code.
- Each library has an 'Extensions' folder where you can find all the necessary configurations for using the library. Call the method(s) you need in the Program.cs file.
# Use Core Services
builder.Services.AddCustomServices();
# Use JWT Authentication tokens
builder.Services.AddJwtSecurity();
# Use Aes Encryption/Decryption methods
builder.Services.AddAesEncryption();
# Use Rsa Encryption/Decryption methods
builder.Services.AddRSAEncryption();
# Use TOTP codes
# IMPORTANT: TOTP uses the AesEncryption library for encrypting its codes.
builder.Services.AddTOTP();
#IMPORTANT: If you need to use JWT tokens, configure the middleware as follows
app.UseMiddleware<JwtAuthenticationMiddelware>();
- Every library uses environment variables. Add them to your project for correct library execution.For development enviroment you can use the launchSettings.json file.