Stateless REST API for HitCheck: users register, send
points (x, y, r) and get back whether each point falls inside a composite area on the plane,
with a personal history of attempts. Authentication is JWT-based on Spring Security 6.
Stack: Java 17 · Spring Boot 3.2 · Spring Security 6 · JWT (jjwt 0.12) · Spring Data JPA · Hibernate · PostgreSQL · MapStruct · springdoc-openapi · Gradle
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/auth/register |
— | Create an account, returns a JWT |
POST |
/auth/login |
— | Log in, returns a JWT |
GET |
/my-shots |
Bearer | History of the current user's points |
POST |
/my-shots |
Bearer | Check a point and save the result |
Swagger UI is available at /swagger-ui/index.html.
sequenceDiagram
participant C as Client
participant F as JwtAuthenticationFilter
participant A as AuthenticationController
participant S as Spring Security
C->>A: POST /auth/login {username, password}
A->>S: AuthenticationManager (DaoAuthenticationProvider + BCrypt)
S-->>A: authenticated
A-->>C: JWT (subject, user id, roles, expiry)
C->>F: GET /my-shots, Authorization: Bearer <token>
F->>F: verify signature and expiry, load user
F->>S: set SecurityContext
S-->>C: 200 with the user's shots only
- Sessions are disabled (
STATELESS), CSRF is off because there are no cookies, CORS is open for the SPA frontend. - Passwords are hashed with BCrypt.
- The token carries the user id and roles as claims, so a request needs no session lookup.
- Validation errors and auth failures are turned into consistent JSON responses by an
@ControllerAdvice. - The hit check lives in the
Shotentity itself, so the rule is applied the same way wherever a shot is created.
# PostgreSQL on localhost:5432, settings in src/main/resources/application.properties
./gradlew bootRun- hitcheck-web: the frontend
- hitcheck-api-jakarta: the same API on Jakarta EE and WildFly
- hitcheck: the full-stack app
Built as coursework for the Web Programming course at ITMO University, 2024.