1
をログインするリダイレクトしないので、動作は次のようである:春のセキュリティKeyCloakアダプタは、私が成功し、それを構成した</p> <p>春のセキュリティKeyCloakアダプタを使用してい
- (1)私はlocalhostに行く場合:8080/XYZ(私のウェブサーバー) - > http://auth-server/auth/realms/にリダイレクト...
- (2)私はローカルホストに行く場合:/ 8080 - > はhttp://auth-server/auth/realms/にリダイレクトされませ...
どうすれば(2)の動作を達成できますか?そのような
@Configuration
@EnableWebSecurity
@ComponentScan(basePackageClasses = KeycloakSecurityComponents.class)
public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
/**
* Registers the KeycloakAuthenticationProvider with the authentication manager.
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(keycloakAuthenticationProvider());
}
@Override
protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
}
@Bean
public FilterRegistrationBean keycloakAuthenticationProcessingFilterRegistrationBean(
KeycloakAuthenticationProcessingFilter filter) {
FilterRegistrationBean registrationBean = new FilterRegistrationBean(filter);
registrationBean.setEnabled(false);
return registrationBean;
}
@Bean
public FilterRegistrationBean keycloakPreAuthActionsFilterRegistrationBean(
KeycloakPreAuthActionsFilter filter) {
FilterRegistrationBean registrationBean = new FilterRegistrationBean(filter);
registrationBean.setEnabled(false);
return registrationBean;
}
@Override
protected KeycloakLogoutHandler keycloakLogoutHandler() throws Exception {
return super.keycloakLogoutHandler();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http
.logout().logoutUrl("/logout").addLogoutHandler(keycloakLogoutHandler())
.and()
.authorizeRequests()
.anyRequest().authenticated();
}
}
回避策は、 'GetMapping("/")'でコントローラを作成し、 'GetMapping("/dashboard' "のようなものにリダイレクトする) –