Skip to content

yj-oh/spring-boot-security-jwt-auth-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” spring-boot-security-jwt-auth-examples

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

🌐 접속 정보

H2 Database

Swagger

πŸ’β€β™€οΈ Endpoints

Endpoint μ„€λͺ…
/auth/signup νšŒμ› κ°€μž…
/auth/login 둜그인
/samples ν…ŒμŠ€νŠΈμš© μƒ˜ν”Œ API (인증 ν•„μš”)
  • μ •μƒμ μœΌλ‘œ 둜그인이 λ˜μ—ˆμ„ λ•Œ μ•„λž˜μ™€ 같은 ν˜•νƒœμ˜ 응닡값을 λ°›μ•„λ³Ό 수 μžˆλ‹€.
{
  "id": 1,
  "email": "test@test.com",
  "username": "λ§ˆμ΄ν¬μ™€μ‘°μŠ€ν‚€",
  "tokenType": "Bearer",
  "token": {JWT}
}

πŸ—‚ Structure

πŸ—‚ 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 μ„€μ • 파일

Releases

No releases published

Packages

No packages published

Languages