Assuming a basic ASP Net API is already existing and using JWT as method of authentication. ASP Net Rest API – Authenticate – JWT
To ensure authentication work as expected, let’s add unittests.
Continue reading “ASP Net JWT Authentication – Test”Requirement engineering, coding, photography
Assuming a basic ASP Net API is already existing and using JWT as method of authentication. ASP Net Rest API – Authenticate – JWT
To ensure authentication work as expected, let’s add unittests.
Continue reading “ASP Net JWT Authentication – Test”As not everything should be available to everyone and some things need to have relation to using user. Let’s now add authentication.
The currently most used technique for this is JSON Web Token (JWT).
JWT means, that after authentication, the user is given a small JSON object aka. Token, that contains basic information about the user. This Token is then send by the user with every request and the server will just read it and take the information out of it.
Awesome is, that therefore the user is holding the key, if multiple services are offered, the user just needs to use this key over and over and the services can directly use data from within it.
BUT, you may ask: Trusting data from user is the biggest risk and a nightmare for security!
Continue reading “ASP Net Rest API – Authenticate – JWT”Previously a basic API for Sights and facts was created ASP Net Rest API – Treasure Hunt – Guess checking.
Now let’s automate “playing” with the API by using and writing Unit Tests.
Create a new Project for the unit tests and add existing Server Project as dependency.
dotnet new xunit -o Tests
cd Tests
dotnet add reference ..\Server
dotnet add package Microsoft.AspNetCore.Mvc.Hosting
dotnet add package Microsoft.AspNetCore.Mvc.Testing
dotnet sln add Tests\
As Rest API is set up and basic models are created ASP Net Rest API – Treasure Hunt, let’s now add some functionality to check if a guess is correct.
For this a API Endpoint is needed that gets a location and the Sight to be guessed.
Thanks to https://www.movable-type.co.uk/scripts/latlong.html theres no need to do the geometry and calculus to get distance or direction between 2 locations on a sphere.
Continue reading “ASP Net Rest API – Treasure Hunt – Guess checking”OK, we already setup a basic project with the prepared Blazor Wasm template and added Swagger. ASP Net Rest API – Swagger
Now let’s add a basic API for our Treasure Hunt.
First question is: What do we actually want to send back and forth?
For our idea of a Treasure Hunt game, the entity structure could look like:
Continue reading “ASP Net Rest API – Treasure Hunt”Now let’s focus on how we can set up communication between client and server.
To begin we as so often start with the basic Blazor Webassembly template, but this time ignore the Frontend part.
dotnet new blazorwasm -o tryout_blazor_api --hosted
As well as changing the ports to run on to 8443 for SSL and 8080 for pure HTTP.
"applicationUrl": "https://localhost:8443;http://localhost:8080",
"applicationUrl": "https://localhost:8443;http://localhost:8080",
The resulting code should be like: https://github.com/sukapx/tryout_blazor_api/tree/76fed6f2e3fe1c963aa3bb8c8ff68528e8139a6d
Continue reading “ASP Net Rest API – Swagger”