我是Keycloak的新手,我正在使用官方教程项目
https://github.com/sebastienblanc/spring-boot-keycloak-tutorial
为了与Springboot应用程序集成,我已经成功设置了KeyCloak服务器,并且Spring引导应用程序也指向我在KeyCloak上创建的Realm上创建的客户端应用程序,之后提供了它指向禁止页面的正确凭据.
@H_403_9@@Controller class ProductController { @GetMapping(path = "/products") public String getProducts(Model model){ model.addAttribute("products",Arrays.asList("iPad","iPhone","iPod")); return "products"; } @GetMapping(path = "/logout") public String logout(HttpServletRequest request) throws ServletException { request.logout(); return "/"; } }
Application.properties文件
@H_403_9@keycloak.auth-server-url=http://localhost:8080/auth keycloak.realm=springdemo keycloak.resource=product-app keycloak.public-client=true keycloak.security-constraints[0].authRoles[0]=testuser keycloak.security- constraints[0].securityCollections[0].patterns[0]=/products/* server.port=8081
我没有从KeyCloak控制台或spring嵌入式tomcat控制台收到任何错误消息.
Check the tomcat console here – no error
谢谢.
最佳答案