Skip to content

Commit

Permalink
Update OAuth2ResourceServer config - Spring Security quickstart
Browse files Browse the repository at this point in the history
Closes (#622)

Signed-off-by: Dami <[email protected]>
  • Loading branch information
adropofliquid authored and mposolda committed Nov 15, 2024
1 parent 24c927e commit 6f84e68
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
import org.springframework.security.oauth2.server.resource.web.authentication.BearerTokenAuthenticationFilter;
import org.springframework.security.web.SecurityFilterChain;
import static org.springframework.security.config.Customizer.withDefaults;

/**
* OAuth resource configuration.
Expand All @@ -53,7 +53,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt)
.oauth2ResourceServer((oauth2) -> oauth2
.jwt(withDefaults())
)
.addFilterAfter(createPolicyEnforcerFilter(), BearerTokenAuthenticationFilter.class);
return http.build();
}
Expand Down

0 comments on commit 6f84e68

Please sign in to comment.