Я интегрировал keycloak с устаревшим весенним приложением. Я добавил адаптер безопасности keycloak spring в свой файл pom.xml и добавил конфигурацию безопасности. После всего, что сделано, я могу получить доступ к остальным API без токена. Как мне решить эту проблему?
@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());
}
/**
* Defines the session authentication strategy.
*/
@Bean
@Override
protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
}
@Override
protected void configure(HttpSecurity http) throws Exception
{
super.configure(http);
http
.authorizeRequests()
.antMatchers("/school-admin*").hasRole("ADMIN")
.anyRequest().permitAll();
}
}
keycloak.json
{
"realm": "appscook",
"bearer-only": true,
"auth-server-url": "http://localhost:8080/auth",
"ssl-required": "external",
"resource": "ssd-backend"
}
API
@RequestMapping(value="/hello",method=RequestMethod.GET)
@ResponseBody
public String getStandards(){
return "hello";
}