Spring Security & JWTμ μΉν΄μ§κΈ°
- Spring Boot
2.5.6
- Spring Security
- Spring Data JPA
- Java 11
- Gradle
- H2 Database
# Clone this repo
git clone https://github.com/yj-oh/spring-boot-security-jwt-auth-examples.git
# Change directory
cd spring-boot-security-jwt-auth-examples
# Start the Server
./gradlew bootRun
- Port
8080
Endpoint | μ€λͺ |
---|---|
/auth/signup | νμ κ°μ |
/auth/login | λ‘κ·ΈμΈ |
/samples | ν μ€νΈμ© μν API (μΈμ¦ νμ) |
- μ μμ μΌλ‘ λ‘κ·ΈμΈμ΄ λμμ λ μλμ κ°μ ννμ μλ΅κ°μ λ°μλ³Ό μ μλ€.
{
"id": 1,
"email": "test@test.com",
"username": "λ§μ΄ν¬μμ‘°μ€ν€",
"tokenType": "Bearer",
"token": {JWT}
}
π spring-boot-security-jwt-auth-examples
|ββ π src
| `ββ π main
| |ββ π java
| | `ββ com.yjworld.jwt
| | |ββ π common # 곡ν΅μΌλ‘ μ°μ΄λ νμΌλ€
| | | |ββ π CommonError.java # μμΈ νΈλ€λ§νκΈ° μν κ³΅ν΅ λͺ¨λΈ
| | | `ββ π CustomExceptionHandler.java # μμΈ νΈλ€λ§
| | |ββ π config # μ€μ νμΌλ€
| | | |ββ π jwt
| | | | |ββ π JwtAuthenticationEntryPoint.java # μΈμ¦ μ€ν¨ μ μμΈ νΈλ€λ§
| | | | |ββ π JwtAuthenticationFilter.java # μΈμ¦ νν°
| | | | `ββ π JwtUtils.java # ν ν° μμ±, parsing, κ²μ¦ λ±μ λ©μλ λͺ¨μ
| | | |ββ π security
| | | | |ββ π UserDetailsImpl.java # UserDetails ꡬν
| | | | `ββ π UserDetailsServiceImpl.java # UserDetailsService ꡬν
| | | |ββ π SecurityConfig.java # Security μ€μ
| | | `ββ π SwaggerConfig.java # Swagger μ€μ
| | |ββ π domain
| | | |ββ π auth # μΈμ¦ κ΄λ ¨ API, λ‘μ§
| | | |ββ π common # API λ 벨μμ 곡ν΅μΌλ‘ μ°μ΄λ νμΌλ€
| | | | `ββ π AuditCreatedAndUpdated.java # μμ±μΌμ, μμ μΌμ κ³΅ν΅ μ»¬λΌ
| | | |ββ π sample # ν
μ€νΈμ© μν API
| | | `ββ π user # User κ΄λ ¨ λ‘μ§
| | `ββ π SpringSecurityJwtApplication.java
| `ββ π resources
| `ββ π application.yml
`ββ π build.gradle # Gradle μ€μ νμΌ