# login_service **Repository Path**: svs_2/login_service ## Basic Information - **Project Name**: login_service - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-13 - **Last Updated**: 2026-06-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Login Service Spring Boot JWT Authentication Service ## Tech Stack - Java 17 - Spring Boot 3.2.5 - Spring Security - Spring Data JPA - MySQL 8.0 - JWT (jjwt 0.12.5) - Docker & Docker Compose ## Features - User registration (username, email, password) - User login with JWT token - Password encryption with BCrypt - Refresh token support - Stateless session management - CORS support - RESTful API ## API Endpoints ### Authentication | Method | Endpoint | Description | |--------|----------|-------------| | POST | `/api/auth/register` | Register new user | | POST | `/api/auth/login` | Login and get JWT token | | POST | `/api/auth/refresh` | Refresh access token | | POST | `/api/auth/logout` | Logout and revoke tokens | ### User | Method | Endpoint | Description | |--------|----------|-------------| | GET | `/api/users/me` | Get current user info | ## Usage ### Register ```bash curl -X POST http://localhost:8080/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "username": "testuser", "email": "test@example.com", "password": "password123" }' ``` Response: ```json { "success": true, "message": "Registration successful", "data": { "token": "eyJhbGciOiJIUzM4NCJ9...", "refreshToken": "uuid-refresh-token", "username": "testuser", "email": "test@example.com", "message": "Success" } } ``` ### Login ```bash curl -X POST http://localhost:8080/api/auth/login \ -H "Content-Type: application/json" \ -d '{ "username": "testuser", "password": "password123" }' ``` ### Get Current User ```bash curl -X GET http://localhost:8080/api/users/me \ -H "Authorization: Bearer " ``` ### Refresh Token ```bash curl -X POST http://localhost:8080/api/auth/refresh \ -H "Content-Type: application/json" \ -d '{"refreshToken": "your-refresh-token"}' ``` ## Database Setup Execute the SQL schema file: ```bash mysql -h 101.37.159.205 -u root -p < sql/schema.sql ``` ## Docker Deployment ### Build and Run ```bash docker-compose up -d ``` ### Stop Services ```bash docker-compose down ``` ## Environment Variables | Variable | Default | Description | |----------|---------|-------------| | `DB_HOST` | 101.37.159.205 | MySQL host | | `DB_PORT` | 3306 | MySQL port | | `DB_NAME` | login_service | Database name | | `DB_USERNAME` | root | Database username | | `DB_PASSWORD` | root | Database password | | `JWT_SECRET` | (base64 key) | JWT signing key | | `JWT_EXPIRATION` | 86400000 | Access token expiration (ms, 24h) | | `JWT_REFRESH_EXPIRATION` | 604800000 | Refresh token expiration (ms, 7d) | | `APP_PORT` | 8080 | Application port | ## Local Development ### Prerequisites - JDK 17+ - Maven 3.9+ - MySQL 8.0 ### Build ```bash mvn clean package -DskipTests ``` ### Run ```bash java -jar target/login-service-1.0.0.jar ``` ## Project Structure ``` login_service/ ├── sql/ │ └── schema.sql # Database schema ├── src/main/java/com/example/loginservice/ │ ├── LoginServiceApplication.java │ ├── config/ │ │ └── SecurityConfig.java │ ├── controller/ │ │ ├── AuthController.java │ │ └── UserController.java │ ├── dto/ │ │ ├── ApiResponse.java │ │ ├── AuthResponse.java │ │ ├── LoginRequest.java │ │ ├── RegisterRequest.java │ │ └── TokenResponse.java │ ├── entity/ │ │ ├── RefreshToken.java │ │ ├── User.java │ │ └── VerificationCode.java │ ├── exception/ │ │ └── GlobalExceptionHandler.java │ ├── repository/ │ │ ├── RefreshTokenRepository.java │ │ ├── UserRepository.java │ │ └── VerificationCodeRepository.java │ ├── security/ │ │ ├── CustomUserDetailsService.java │ │ ├── JwtAuthenticationFilter.java │ │ └── JwtTokenProvider.java │ └── service/ │ ├── AuthService.java │ ├── UserService.java │ └── VerificationCodeService.java ├── src/main/resources/ │ └── application.yml ├── Dockerfile ├── docker-compose.yml ├── pom.xml └── README.md ```