我尝试通过一些简化来重现
https://www.baeldung.com/spring-boot-keycloak
教程。我的 Keycloak 服务器也在另一台机器上。由于 antMatchers
: 的弃用,配置也略有变化
http.authorizeHttpRequests((requests) -> requests
.requestMatchers("/customers*")
.hasRole("user")
.anyRequest()
.permitAll()
);
不受保护的资源有效,登录有效,但在登录重定向后我得到 403。控制台或浏览器中没有消息。我试图禁用 CORS 和/或 CSRF,同样。
有了关于您的配置和错误的信息级别,我只能建议