2017-05-18 8 views
1

をログインするリダイレクトしないので、動作は次のようである:春のセキュリティKeyCloakアダプタは、私が成功し、それを構成した</p> <p>春のセキュリティKeyCloakアダプタを使用してい

どうすれば(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(); 
} 

}

答えて

1

何かがトリックを行う必要があります:

http 
    .authorizeRequests() 
    .antMatchers("/xyz*").hasRole("user") //replace with your role 
    .anyRequest().permitAll(); 
0

私は同じ問題を持っている

この

は春のセキュリティ設定です。 http://localhost:8080/myappはリダイレクトされませんが、 http://localhost:8080/myapp/index.htmlがあります。あなたはその間に解決策を見つけることができますか?

+0

回避策は、 'GetMapping("/")'でコントローラを作成し、 'GetMapping("/dashboard' "のようなものにリダイレクトする) –

関連する問題