The JWT Authorization Spring Boot Starter is designed to simplify the implementation of JSON Web Token (JWT) based authentication and authorization within Spring Boot applications. This starter provides a robust foundation for developers looking to secure their Spring Boot applications using JWT, a widely adopted industry standard for token-based authentication.
- JWT-based authentication for secure REST APIs.
- Easy integration with Spring Boot applications.
- Based on Spring Security.
Add the dependency to your project.
<dependency>
<groupId>dev.junsung</groupId>
<artifactId>jwt-auth-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
implementation("dev.junsung:jwt-auth-spring-boot-starter:0.2.0")
Include the following dependencies in your build.gradle.kts
file:
dependencies {
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
implementation("dev.junsung:jwt-auth-spring-boot-starter:0.2.0")
}
Set up your SecurityFilterChain to include JWT authentication. Add authorizationServer
configuration as shown
below:
@Configuration
@EnableWebSecurity
class SecurityConfig {
@Bean
fun filterChain(http: HttpSecurity): SecurityFilterChain {
return http
// Additional security configurations...
.oauth2ResourceServer { it.jwt {} }
.authorizationServer { }
.build()
}
}
- The JWT Auth Spring Boot Starter depends on Spring Security's OAuth2 components.
- Ensure you have the proper Spring Security configurations to protect your endpoints.