This repository contains a skeleton application and a series of guides on how to manually implement authentication, session management and authorization with ASP.NET as backend and React as frontend.
The skeleton application is a simple blog with posts and comments.
In real-world systems, I recommend using ASP.NET Identity instead of implementing authentication and sessions manually. However, it is important that you know how this stuff works, and I believe in learning by coding.
Fork the repository and clone it to your computer.
There is a script named setup.sh and you simply run the script.
./setup.sh <some-password>Replace <some-password> with what you want to use as password for the
preconfigured users.
In case you forget the password, or just want to reset, simply run the script again.
Before first run, you need to install dependencies with:
npm ci --prefix clientThen start development web server with:
npm run dev --prefix clientThe --prefix client tells npm to behave as if you were running it from
client/ folder.
That way do don't have to cd around all the time.
dotnet watch --project server/ApiThe watch part makes it hot-reload when you change the code. Not all changes
works with hot-reloading, in which case you need to manually restart it with
CTRL+R.
| Sub-systems | URL |
|---|---|
| Client / frontend | http://localhost:5173/ |
| Server / backend | http://localhost:5153/scalar/ |
The project uses Scalar, which is an alternative to Swagger UI.
| Parameter | Value |
|---|---|
| URL | jdbc:postgresql://localhost:5432/postgres |
| Username | postgres |
| Password | mysecret |
| Connection string | HOST=localhost;DB=postgres;UID=postgres;PWD=mysecret;PORT=5432; |
The application ships with some test data, including blog posts and a couple of users. After implementing authentication, you will be able to log-in using these credentials:
| Email / Username | Role |
|---|---|
| admin@example.com | Admin |
| editor@example.com | Editor |
| othereditor@example.com | Editor |
| reader@example.com | Reader |
Complete these exercises in order. Since each builds on the previous. Make a commit each time you complete an exercise.