Reputation: 9
my setup is the following:
I want to use the BFF architecture but i have trouble with cookies? redirects? I dont get it anymore.
The flow would look like this:
User → Gateway → Auth-Server Auth-Server → Google Google → Auth-Server Auth-Server → Gateway Gateway → User
Auth Server:
server:
port: 9000
logging:
level:
org.springframework.security: TRACE
spring:
datasource:
url: jdbc:postgresql://localhost:5432/adkit_db
username: user
password: password
sql:
init:
mode: always
security:
user:
name: user
password: password
oauth2:
authorizationserver:
client:
client-1:
registration:
client-id: "client"
client-secret: "{noop}secret"
client-authentication-methods:
- "client_secret_basic"
authorization-grant-types:
- "authorization_code"
- "refresh_token"
- "client_credentials"
redirect-uris:
- "http://127.0.0.1:8080/login/oauth2/code/adkit"
post-logout-redirect-uris:
- "http://127.0.0.1:8080/"
scopes:
- "openid"
- "profile"
- "email"
require-authorization-consent: true
client:
registration:
google:
client-id: xya
client-secret: bza
scope:
- openid
- profile
- email
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
@Order(1)
SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
OAuth2AuthorizationServerConfigurer authorizationServerConfigurer =
OAuth2AuthorizationServerConfigurer.authorizationServer();
http
.securityMatcher(authorizationServerConfigurer.getEndpointsMatcher())
.with(authorizationServerConfigurer, (authorizationServer) ->
authorizationServer
.oidc(Customizer.withDefaults()) // Enable OpenID Connect 1.0
)
// Redirect to the login page when not authenticated from the
// authorization endpoint
.exceptionHandling((exceptions) -> exceptions
.defaultAuthenticationEntryPointFor(
new LoginUrlAuthenticationEntryPoint("/login"),
new MediaTypeRequestMatcher(MediaType.TEXT_HTML)
)
);
return http.build();
}
@Bean
@Order(2)
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(authorizeRequests -> authorizeRequests.anyRequest().authenticated())
.oauth2Client(withDefaults())
.oauth2Login(withDefaults())
.formLogin(withDefaults());
return http.build();
}
private AuthenticationSuccessHandler authenticationSuccessHandler() {
return new FederatedIdentityAuthenticationSuccessHandler();
}
Upvotes: 0
Views: 19