{"id":16933507,"url":"https://github.com/cannon07/jwtsecuritytestproject","last_synced_at":"2025-06-26T12:32:13.028Z","repository":{"id":189995232,"uuid":"681477730","full_name":"Cannon07/jwtSecurityTestProject","owner":"Cannon07","description":"Exploring JWT (JSON Web Tokens) authentication in a Spring Boot project.","archived":false,"fork":false,"pushed_at":"2023-08-22T16:48:26.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T03:43:26.754Z","etag":null,"topics":["authentication","jwt","jwt-authentication","rest-api","spring-security"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Cannon07.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}},"created_at":"2023-08-22T05:29:55.000Z","updated_at":"2023-09-23T07:42:03.000Z","dependencies_parsed_at":"2023-08-22T20:43:04.329Z","dependency_job_id":null,"html_url":"https://github.com/Cannon07/jwtSecurityTestProject","commit_stats":null,"previous_names":["cannon07/jwtsecuritytestproject"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cannon07/jwtSecurityTestProject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cannon07%2FjwtSecurityTestProject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cannon07%2FjwtSecurityTestProject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cannon07%2FjwtSecurityTestProject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cannon07%2FjwtSecurityTestProject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cannon07","download_url":"https://codeload.github.com/Cannon07/jwtSecurityTestProject/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cannon07%2FjwtSecurityTestProject/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262068164,"owners_count":23253754,"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","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":["authentication","jwt","jwt-authentication","rest-api","spring-security"],"created_at":"2024-10-13T20:49:39.021Z","updated_at":"2025-06-26T12:32:13.010Z","avatar_url":"https://github.com/Cannon07.png","language":"Java","readme":"# Spring Boot JWT Token Example\n\nThis project is a practical exploration of implementing JWT (JSON Web Tokens) authentication in a Spring Boot application. JSON Web Tokens are a widely used standard for securely transmitting information between parties as a JSON object. This project provides a hands-on introduction to the concepts of authentication, token generation, and verification using JWTs.\n\n## Key Features\n\n- **JWT Authentication:** Learn how to integrate JWT-based authentication into a Spring Boot application.\n- **Token Generation:** Understand the process of generating JWT tokens containing user information.\n- **Token Validation:** Implement token validation to ensure the authenticity and integrity of transmitted data.\n- **User Management:** Explore how to manage user data and roles in the context of JWT authentication.\n- **API Endpoints:** Set up secure API endpoints that require valid JWT tokens for access.\n- **Security Configuration:** Gain insights into Spring Security configurations for JWT-based authentication.\n\n## Technologies Used\n\n- Spring Boot\n- Spring Security\n- JSON Web Tokens (JWT)\n- Java Persistence API (JPA)\n- Maven for project management\n- RESTful API design principles\n\n## Getting Started\n\n1. Clone the repository to your local machine.\n2. Configure your database settings in `application.properties`.\n3. Run the application using your preferred IDE or the command line.\n4. Access the API endpoints, understanding how JWT tokens are used for authentication.\n\n## API Endpoints\n\n### 1. Register User\n\n**Endpoint:** `POST /api/v1/auth/register`\n\nThis endpoint allows users to register by providing their username and password. Upon successful registration, the user's information is stored securely in the database.\n\n#### Request\n\nPOST /api/v1/auth/register  \nContent-Type: application/json\n\n``` json\n{\n    \"firstName\": \"new\",\n    \"lastName\": \"user\",\n    \"email\": \"newuser@email.com\",\n    \"password\": \"1234\"\n}\n```\n#### Response\n\nHTTP/1.1 200 OK\n\n``` json\n{\n    \"token\": \"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuZXd1c2VyQGVtYWlsLmNvbSIsImlhdCI6MTY5MjcyMDA4NCwiZXhwIjoxNjkyNzIxNTI0fQ.HwN99fq4SFZMogv74MerdHJuxuALghLKWsowNerekqo\"\n}\n```\n\n### 2. Authenticate User\n\n**Endpoint:** `POST /api/v1/auth/authenticate`\n\nThis endpoint allows users to authenticate by providing their registered username and password. Upon successful authentication, a JWT token is returned, which is required for accessing the authenticated endpoint.\n\n#### Request\n\nPOST /api/auth/authenticate  \nContent-Type: application/json  \n\n``` json\n{\n    \"email\": \"newuser@email.com\",\n    \"password\": \"1234\"\n}\n```\n#### Response\n\nHTTP/1.1 200 OK\n\n``` json\n{\n    \"token\": \"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuZXd1c2VyQGVtYWlsLmNvbSIsImlhdCI6MTY5MjcyMDA4NCwiZXhwIjoxNjkyNzIxNTI0fQ.HwN99fq4SFZMogv74MerdHJuxuALghLKWsowNerekqo\"\n}\n```\n\n### 3. Authenticated Endpoint\n\n**Endpoint:** `GET /api/v1/demo-controller`\n\nThis is a secure endpoint that requires a valid JWT token to access. Users need to include the received token in the request header to access this endpoint.\n\n#### Request\n\nGET /api/v1/demo-controller  \nAuthorization: Bearer your_generated_jwt_token \n\n#### Response\n\nHTTP/1.1 200 OK\n\n``` json\n{\n    \"message\": \"Hello From Secured Endpoint\"\n}\n```\n\n\n## Usage\n\nThis project serves as a hands-on reference for implementing JWT-based authentication in Spring Boot applications. It's designed for developers who want to grasp the core concepts of JWTs and their application in securing RESTful APIs.\n\n## Contributions\n\nContributions are welcome! If you find any issues or want to enhance the project, feel free to fork the repository and submit pull requests.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcannon07%2Fjwtsecuritytestproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcannon07%2Fjwtsecuritytestproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcannon07%2Fjwtsecuritytestproject/lists"}