Hello guys, I am happy to share a project with you in order to show you what I am currently studying.
This project aims to create a Logger for client-server requests in .NET Core APIs.
I can determine the time elapsed in the request, which HTTP method was returned by the server, which Status Code is returned, address path, and creation date and other things.
As for security, the application encrypts all logs with AES-128 bit encryption, in the future I intend to make changes to AES-512 bits. Only high-level administrators with password you can access readable information from the log files. When logging, we save in a database and we save the encrypted data in a binary file. The admin user with a password you can decrypt the information in the log file to perform an audit.
- Elapsed time
- Http Method
- Address
- CreatedAt
- UpdatedAt
- ClientCode
The intention is to generate a Nuget package for the community as a logging option for APIs.
Start by setting the variables inside appsettings.json, see the example below, in it we're going to configure a 16-byte encryption key, choose a 16-byte/character key of your choice:
{
"SecuritySession": {
"SecretKey": "50GT0FC2E5D6RNG7",
"KeyForBookResource": "fdsgçoaiglkajdfhd"
}
}
After that, we'll configure the pathnames and files for encryption and decryption. See the example below (extension is optional, choose in honor of my name: Yuri <3):
{
"FileConfigSession": {
"FilePathForEncrypt": "C:\\Users\\YuriMelo\\Documents",
"FilePathForDecrypt": "C:\\Users\\YuriMelo\\Documents",
"FileNameForEncrypt": "RequestTrace.yur",
"FileNameForDecrypt": "DecryptedRequestTrace.yur"
}
}