{"id":20565905,"url":"https://github.com/dotnetbackendtraining/authenticated-web-app","last_synced_at":"2026-05-18T06:36:24.652Z","repository":{"id":246590248,"uuid":"815557827","full_name":"DotNetBackendTraining/authenticated-web-app","owner":"DotNetBackendTraining","description":"Startup ASP.NET Core app with essential functionalities (Authentication, Dockerization, Settings, etc...)","archived":false,"fork":false,"pushed_at":"2024-07-08T14:37:03.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T08:57:32.420Z","etag":null,"topics":["asp-net","efcore","exercise","jwt-authentication","postman","rate-limiting","starter-template"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DotNetBackendTraining.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-15T13:13:33.000Z","updated_at":"2024-07-08T14:36:53.000Z","dependencies_parsed_at":"2024-07-08T17:46:55.015Z","dependency_job_id":"6126b47d-76a8-465b-a3ef-bc83375e5156","html_url":"https://github.com/DotNetBackendTraining/authenticated-web-app","commit_stats":null,"previous_names":["dotnetbackendtraining/authenticated-web-app"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/DotNetBackendTraining/authenticated-web-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DotNetBackendTraining%2Fauthenticated-web-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DotNetBackendTraining%2Fauthenticated-web-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DotNetBackendTraining%2Fauthenticated-web-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DotNetBackendTraining%2Fauthenticated-web-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DotNetBackendTraining","download_url":"https://codeload.github.com/DotNetBackendTraining/authenticated-web-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DotNetBackendTraining%2Fauthenticated-web-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270907431,"owners_count":24665962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net","efcore","exercise","jwt-authentication","postman","rate-limiting","starter-template"],"created_at":"2024-11-16T04:39:29.073Z","updated_at":"2026-05-18T06:36:19.612Z","avatar_url":"https://github.com/DotNetBackendTraining.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Authenticated Web App\n\n## Overview\n\nThis is a startup web app with essential functionalities:\n\n1. Authentication with JWT\n2. Rate Limiting \u0026 CORS settings\n3. Dockerization (and docker compose)\n4. EFCore \u0026 DbContext\n5. Production \u0026 Development settings\n\n## Development\n\n1. Fill the variables in `example.env` and rename the file to `.env`\n2. Run `docker-compose.development.yml`, you can use the following command:\n   ```shell\n   docker-compose -f \"docker-compose.development.yml\" up -d\n   ```\n3. Import `Development.postman_collection.json` to postman for testing.\n\n## Creating this project as an Exercise:\n\nIn this exercise, you will learn how to create a minimal ASP.NET Web API and implement JWT (JSON Web Token)\nauthentication.\n\n### **Step 1: Setting up the Project**\n\n1. Create a new ASP.NET Web API project.\n2. Configure the project with the necessary dependencies, such as **`Microsoft.AspNetCore.Authentication.JwtBearer`**\n   package, which provides JWT authentication support.\n\n### **Step 2: Implementing JWT Authentication**\n\n1. Create a class called **`JwtTokenGenerator`** that will be responsible for generating and validating JWT tokens.\n2. Inside the **`JwtTokenGenerator`** class, implement a method called **`GenerateToken`** that takes in user\n   credentials (e.g., username and password) and returns a JWT token.\n3. Use the **`System.IdentityModel.Tokens.Jwt`** namespace to create and sign the JWT token. You can use a secure key or\n   a certificate to sign the token.\n4. Implement another method called **`ValidateToken`** that takes in a JWT token and verifies its validity, including\n   the signature and expiration date.\n\n### **Step 3: Creating the API Controller**\n\n1. Create an API controller class that will handle the requests and responses for your API.\n2. Apply the **`[Authorize]`** attribute to the controller or specific actions that require authentication.\n3. Create a get method that will return today’s weather or a welcome message, just to show the user that he is\n   authorized and has access to the system.\n\n### **Step 4: Configuring JWT Authentication**\n\n1. Open the **`Startup.cs`** file in your project.\n2. In the **`ConfigureServices`** method, configure JWT authentication using the **`AddAuthentication`** method and\n   specify the JWT bearer options.\n3. Provide the necessary configuration details such as the issuer, audience, and token validation parameters.\n4. In the **`Configure`** method, add the **`UseAuthentication`** middleware to enable authentication in your API.\n\n### **Step 5: Testing the API**\n\n1. Build and run your API project.\n2. Use a tool like Postman or curl to send HTTP requests to your API endpoints.\n3. For authenticated endpoints, include the JWT token in the request headers using the **`Authorization`** header. The\n   token should be in the format **`Bearer \u003ctoken\u003e`**.\n4. Test both authenticated and unauthenticated endpoints to ensure that the authentication is working as expected.\n\n### **Conclusion**\n\nIn this exercise, you have learned how to create a minimal ASP.NET Web API and implement JWT authentication. This\nprovides a secure way to authenticate and authorize requests to your API endpoints. By understanding the concepts and\nfollowing the steps outlined in this exercise, you are now equipped with the knowledge to build more complex APIs with\nJWT authentication in the future.\n\nRemember to document your code thoroughly and explain any additional features or enhancements you may have implemented.\nGood luck with your exercise!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnetbackendtraining%2Fauthenticated-web-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnetbackendtraining%2Fauthenticated-web-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnetbackendtraining%2Fauthenticated-web-app/lists"}