Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Spring Boot 3.1 & Spring Security 6 : Token Based Authentication example with JWT, Authorization, Spring Data & PostgreSQL

NotificationsYou must be signed in to change notification settings

MossaabFrifita/spring-boot-3-security-6-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository showcases a project that demonstrates the implementation of JSON Web Tokens (JWT) with Spring Boot 3 and Spring Security 6. The project includes the following functionalities:

  • User Registration and Login with JWT Authentication
  • Refresh Token stored in db
  • Role-Based Authorization with authorities
  • Customized Access Denied Handling
  • OpenAPI Documentation Integration (Swagger)

Technologies

  • Spring Boot 3.1
  • Spring Security
  • Spring Data JPA
  • Spring Boot custom Validation
  • JSON Web Tokens(JWT)
  • BCrypt
  • Maven
  • OpenAPI(SpringDoc Impl)
  • Lombok

Getting Started

To get started with this project, you will need to have the following installed on your local machine:

  • JDK 17+
  • Maven 3+

Configure Spring Datasource, JPA, App properties

  1. Clone the repository
  2. Open src/main/resources/application.yml
spring:  datasource:    driver-class-name: org.postgresql.Driver    url: jdbc:postgresql://localhost:5432/db_security    username: postgres    password: ${POSTGRES_PASSWORD}  jpa:    hibernate:      ddl-auto: create    show-sql: true    properties:      hibernate:        format_sql: true    database: postgresql    database-platform: org.hibernate.dialect.PostgreSQLDialectserver:  port: 8086application:  security:    jwt:      secret-key: 586B633834416E396D7436753879382F423F4428482B4C6250655367566B5970      expiration: 86400000 # a day      refresh-token:        expiration: 604800000 # 7 days

Build and run the Project

  • Build the project:mvn clean install
  • Run the project:mvn spring-boot:run

The application will be available athttp://localhost:8086.

Test project

User registration endpoint

POST http://localhost:8086/api/v1/auth/register

register

For detailed documentation and testing of the APIs, access the Swagger UI by visiting:

http://localhost:8086/swagger-ui.html

About

Spring Boot 3.1 & Spring Security 6 : Token Based Authentication example with JWT, Authorization, Spring Data & PostgreSQL

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp