This is an assessment project.
You have to install .NET 6 SDK to run this project. You can find it on official Microsoft site.
Pull the repo from your favourite IDE(preferably Rider or Visual Studio), it should automatically restore the installed packages. If not, use command below
dotnet restore
Afterwards, you should be able to build the project from your IDE.
To run the project, you need to create some User Secrets which are basically,
- "JwtSettings:Secret" to "super-secret-key"
- "JwtSettings:Issuer" to "test"
- "JwtSettings:ExpiryMinutes" to 60
- "JwtSettings:Audience" to "test"
- "ConnectionStrings:sqlConnection" to your connection string to your database
First go to your terminal and change directory to project file.
cd .\Umelle24February2023BurakOzenc\
And then initialize a user-secret id for the project with command below.
dotnet user-secrets init
You can set the user secrets with the command below.
dotnet user-secrets set "JwtSettings:Secret" "super-secret-key"
The encryption algorithm 'HS256' requires a key size of at least 128 bits. So your "JwtSettings:Secret" key should have at least 128 bits(or 16 characters).
For database context, you need to create a first migration using command below.
dotnet ef add migrations initialMigration
And should update the database using command below.
dotnet ef database update
Now the project is ready to run.
Run your project and a Swagger window will pop up.
POST 200 OK
Limitations for email field:
- Should be a legit email.
- Can not exceed 244 characters.
Limitations for password field:
- Cannot exceed 40 characters.
This method will return a Bearer token which we will use to reach to authenticated method.
GET 200 OK
This method should be called from Postman or any application that you can send header data within your request. You should use the token returned from User/CreateUser method. If your authentication succeeded, you will receive 4 random numbers between 0 and 100.
Here are some notes about this small project.
Since it is a small project, I have not created separate projects for domain, infrastructure and application layers.
But folder structure is well-designed, named with main logics and easy to understand.
You have enough flexibility to change the database from MSSQL to any choice of yours. Just need to update the methods on persistence/repository folder.
Project sticks to the OOP principles.