Spring Resource Server

Spring%20Resource%20Server%20Docs 2088E9?logo=quickLook&logoColor=white Spring%20Boot%20Resource%20Server%20Docs 2088E9?logo=quickLook&logoColor=white

Maven Dependency

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>

Getting Started

Example

To set up OAuth 2.0 Resource Server, you need to create 🟢 SecurityConfig:

@Configuration
public class SecurityConfig {

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
        httpSecurity.authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated()) (1)
                .oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults())); (2)
        return httpSecurity.build();
    }

}
1 Require any request to be authenticated
2 Setup OAuth 2.0 Resource Server with JWT support with the defaults

Customizing Authorization Server url

You can customize Authorization Server url with this property

spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:9000