{"id":24599932,"url":"https://github.com/athrocks/spring-jwt-auth-api","last_synced_at":"2026-05-18T01:37:25.194Z","repository":{"id":268833148,"uuid":"905593523","full_name":"athrocks/spring-jwt-auth-API","owner":"athrocks","description":"A Spring Boot backend project implementing secure API authentication using JWT (JSON Web Tokens) and Bcrypt. This project includes role-based access control, integrates with a MySQL database, and provides example endpoints for different roles (Student, User).","archived":false,"fork":false,"pushed_at":"2024-12-20T19:37:56.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T06:47:40.744Z","etag":null,"topics":["jwt","jwt-authentication","jwt-token","mysql","rest-api","restapi","restful-api","spring","spring-boot","spring-data-jpa","spring-mvc","spring-security","springframework"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/athrocks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-12-19T06:27:53.000Z","updated_at":"2025-03-02T09:30:20.000Z","dependencies_parsed_at":"2025-03-18T06:40:45.141Z","dependency_job_id":"165ed9b6-46a8-47e6-9011-7c9b97f1761c","html_url":"https://github.com/athrocks/spring-jwt-auth-API","commit_stats":null,"previous_names":["athrocks/spring-jwt-auth-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/athrocks/spring-jwt-auth-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athrocks%2Fspring-jwt-auth-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athrocks%2Fspring-jwt-auth-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athrocks%2Fspring-jwt-auth-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athrocks%2Fspring-jwt-auth-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athrocks","download_url":"https://codeload.github.com/athrocks/spring-jwt-auth-API/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athrocks%2Fspring-jwt-auth-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33161938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["jwt","jwt-authentication","jwt-token","mysql","rest-api","restapi","restful-api","spring","spring-boot","spring-data-jpa","spring-mvc","spring-security","springframework"],"created_at":"2025-01-24T13:18:04.187Z","updated_at":"2026-05-18T01:37:25.161Z","avatar_url":"https://github.com/athrocks.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot API with JWT Authentication and MySQL\n\n## Overview\nThis is a Spring Boot backend project implementing secure API authentication using **JWT (JSON Web Tokens)** and **Bcrypt** for password hashing. The project connects to a MySQL database and provides basic user registration, login, and CRUD operations for `Student` resources.\n\n---\n\n## Features\n- **JWT-based Authentication**:\n  - Secure login endpoint for token generation.\n  - Token validation and stateless session management.\n- **Password Hashing**:\n  - Secure password storage using Bcrypt.\n- **CSRF Protection**:\n  - CSRF token endpoint for additional security.\n\n---\n\n## Future Planned Features\n\nHere are some planned enhancements for this project:\n1. **Role-Based Authorization**:\n   - Implement `@PreAuthorize` or similar mechanisms to restrict access based on roles (e.g., Admin, User, Student).\n   - Add role-based endpoints for managing sensitive operations.\n2. **Refresh Tokens**:\n   - Add support for refresh tokens to allow seamless JWT renewal.\n3. **Pagination for Student List**:\n   - Implement pagination for the `/students` endpoint to handle large datasets efficiently.\n4. **Improved Error Handling**:\n   - Introduce global exception handling for better API responses.\n5. **Dockerization**:\n   - Create a `Dockerfile` to containerize the application for easy deployment.\n6. **Front-End Integration**:\n   - Build a front-end client using React or Angular for interacting with the API.\n7. **API Documentation**:\n   - Use Swagger/OpenAPI for comprehensive API documentation.\n\n---\n\n## Technologies Used\n- **Spring Boot**: Backend framework\n- **Spring Security**: Authentication \u0026 Authorization\n- **JWT (JSON Web Tokens)**: Token-based authentication\n- **Bcrypt**: Secure password hashing\n- **MySQL**: Relational database\n- **Hibernate/JPA**: ORM for database operations\n\n---\n\n## API Endpoints\n| HTTP Method | Endpoint                | Description                                     |\n|-------------|-------------------------|-------------------------------------------------|\n| `GET`       | `/`                     | Welcome message with session ID.               |\n| `GET`       | `/students`             | Returns a list of all students.                |\n| `POST`      | `/students`             | Adds a new student to the list.                |\n| `GET`       | `/csrf-token`           | Returns a CSRF token.                          |\n| `POST`      | `/register`             | Registers a new user.                          |\n| `POST`      | `/login`                | Authenticates the user and returns a JWT token.|\n\n---\n\n## Setup Instructions\n\n### Prerequisites\n- Java 21+\n- Maven 3.8+\n- MySQL Database\n- IDE (e.g., IntelliJ IDEA)\n\n### Steps to Run\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/athrocks/spring-jwt-auth-API.git\n   cd spring-jwt-auth-API\n   ```\n   \n2. Configure the database:  \nUpdate the application.properties file:  \n  ```bash\n  spring.datasource.url=jdbc:mysql://localhost:3306/your_database\n  spring.datasource.username=your_username\n  spring.datasource.password=your_password\n  ```\n\n3. Build the project:  \n\n  ```bash\n  ./mvnw clean install\n  ```\n\n4. Run the project:\n\n  ```bash\n  ./mvnw spring-boot:run\n  ```\n\n5. Access the API at http://localhost:8080.\n\n---\n\n### Database Schema\n\n  ```sql\n  CREATE TABLE users(\n      id integer primary key,\n      username varchar(50),\n      password varchar(50)\n  );\n  ```\n\n---\n\n### How to Test the API\n\nUse Postman or cURL to test endpoints.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathrocks%2Fspring-jwt-auth-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathrocks%2Fspring-jwt-auth-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathrocks%2Fspring-jwt-auth-api/lists"}