Java 如何解决KeyClope Spring引导应用程序的问题

Java 如何解决KeyClope Spring引导应用程序的问题,java,spring-boot,spring-security,spring-security-oauth2,keycloak,Java,Spring Boot,Spring Security,Spring Security Oauth2,Keycloak,我正在使用KeyClope保护Spring启动应用程序。在我的例子中,我使用keydepot来保护微服务。这些服务互相呼叫。对于呼叫服务,我使用KeyClope的客户端\ U凭据授权。我创建了一个客户机,并使用keydepot属性配置了spring引导。一切都很好,但只有一件事例外。当我向安全端点发送GET请求时,我得到了正确的响应。但是,如果我发送一个POST请求,我会得到一个错误。错误是 "timestamp": "2019-04-17T11:38:39.737+0000", "status

我正在使用KeyClope保护Spring启动应用程序。在我的例子中,我使用keydepot来保护微服务。这些服务互相呼叫。对于呼叫服务,我使用KeyClope的客户端\ U凭据授权。我创建了一个客户机,并使用keydepot属性配置了spring引导。一切都很好,但只有一件事例外。当我向安全端点发送GET请求时,我得到了正确的响应。但是,如果我发送一个POST请求,我会得到一个错误。错误是

"timestamp": "2019-04-17T11:38:39.737+0000",
"status": 403,
"error": "Forbidden",
"message": "Access to the requested resource has been denied",
"path": "/v1/users/register"
我已尝试使用配置Spring boot

##-------------- Keycloak configuration ----------------------------
keycloak.realm=phantomwallet
keycloak.auth-server-url=http://localhost:8080/auth/
keycloak.resource=wallet_client
keycloak.credentials.secret=ebb59830-2abc-4a92-9d67-b6bfb3eb3bd2
keycloak.bearer-only=true
#keycloak.use-resource-role-mappings=true
keycloak.principal-attribute=preferred_username
keycloak.security-constraints[0].auth-roles[0]=client_role
keycloak.security-constraints[0].auth-roles[1]=basic_role
keycloak.security-constraints[0].security- 
collections[0].patterns[0]=/*

尝试在属性文件中添加logging.level.org.keydape=DEBUG,然后检查SpringBoot日志。谢谢。我已经解决了。问题在于csrf。应该禁用它,否则,Spring security会检查csrf,如果请求不是由浏览器设备发送,则会拒绝它。除此之外,我禁用了auth_角色。