Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 2, 2025

This PR implements a complete Java Spring Boot REST API following the provided design specifications. The API provides user management functionality with JWT-based authentication and admin-only authorization.

Key Features Implemented

API Endpoint: GET /api/users/{id}

  • JWT token authentication required
  • Admin role authorization only
  • Returns JSON response with user data (id, name, email, role)
  • Proper HTTP status codes (200, 401, 403, 404)

Technical Implementation

The solution uses:

  • Spring Boot 3.1.5 with Java 17
  • JWT authentication with HMAC-SHA384 signing
  • Spring Security with method-level authorization
  • H2 in-memory database with JPA/Hibernate
  • Global exception handling for proper error responses

Architecture

├── UserController - REST endpoint implementation
├── JwtUtil - JWT token generation and validation
├── JwtAuthenticationFilter - Request authentication filter
├── SecurityConfig - Spring Security configuration
├── User entity - JPA entity with validation
├── UserRepository - Data access layer
└── GlobalExceptionHandler - Centralized error handling

Testing Results

Manual testing confirms all requirements are met:

  • ✅ Admin token access returns user data (200 OK)
  • ✅ Non-admin token access returns 403 Forbidden
  • ✅ Missing token returns 403 Forbidden
  • ✅ Non-existent user returns 404 Not Found with error message

The API includes automatic test data loading and a token generator utility for easy testing. Complete documentation and usage instructions are provided in the README.

Fixes #3.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits September 2, 2025 07:01
Co-authored-by: yus04 <49590084+yus04@users.noreply.github.com>
Co-authored-by: yus04 <49590084+yus04@users.noreply.github.com>
Co-authored-by: yus04 <49590084+yus04@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] 基本設計書に基づいた REST API の実装 Implement REST API with JWT authentication based on design specifications Sep 2, 2025
@Copilot Copilot AI requested a review from yus04 September 2, 2025 07:03
Copilot finished work on behalf of yus04 September 2, 2025 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

基本設計書に基づいた REST API の実装

2 participants