This project demonstrates how to implement JWT (JSON Web Token) Authentication in a Blazor application. It serves as a guide for integrating secure authentication mechanisms in Blazor, using JWT to handle user authentication and authorization.
- 🔒 JWT-based authentication for securing API endpoints.
- 👤 Login and user authentication with token generation.
- 🔐 Token storage and validation using local storage.
- ⚡ Secure API calls using the generated JWT for authorization.
- 🧩 Blazor WebAssembly as the front-end framework.
- Blazor WebAssembly for the client-side.
- ASP.NET Core for the backend.
- JWT (JSON Web Tokens) for authentication and authorization.
- Entity Framework Core for database operations.
-
Clone the repository:
git clone https://github.com/MarvynHarry/Blazor-JTW-Auth.git
-
Navigate to the project folder:
cd Blazor-JWT-Auth
-
Restore dependencies:
dotnet restore
-
Update the
appsettings.json
file with your database connection and JWT secret:{ "ConnectionStrings": { "DefaultConnection": "YourDatabaseConnectionString" }, "JwtSettings": { "SecretKey": "YourSuperSecretKey" } }
-
Run the project:
dotnet run
- Sign up for a new user account.
- Log in to receive a JWT token.
- Use the token to access secure endpoints by passing it in the Authorization header.
Authorization: Bearer your-jwt-token-here
- /Client: Blazor WebAssembly front-end.
- /Server: ASP.NET Core Web API for authentication and data processing.
- /Shared: Shared models and classes between the client and server.
If you enjoy my work or want to support what I do, feel free to Buy Me a Coffee!
Feel free to submit a pull request or report issues to help improve the project!
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or support, please reach out via GitHub Issues.