Created
January 10, 2023 02:22
-
-
Save jei0486/8fcbdf498f7ef7fe7c4cbb51f91851f2 to your computer and use it in GitHub Desktop.
opaque-token-Spring-Security
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.demo.scg.config; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; | |
import org.springframework.security.config.web.server.ServerHttpSecurity; | |
import org.springframework.security.web.server.SecurityWebFilterChain; | |
@Configuration | |
@EnableWebFluxSecurity | |
public class SecurityConfig { | |
@Bean | |
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { | |
// oauth2 Resource | |
http.authorizeExchange(exchanges -> exchanges.anyExchange().authenticated()) | |
.oauth2ResourceServer(oauth2 -> oauth2 | |
.opaqueToken(opaqueToken -> opaqueToken | |
.introspectionUri("http://localhost:8080/auth/realms/demo/protocol/openid-connect/token/introspect") | |
.introspectionClientCredentials("demo-client", "83f3e948-3f8c-49da-af7f-87a42d5ea6fd") | |
) | |
); | |
http.csrf().disable(); | |
return http.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment