1 回答
TA贡献1773条经验 获得超3个赞
如何设置前端 Spring Boot 应用程序以将经过身份验证的用户详细信息传递给后端 Spring Boot 应用程序(RequestInterceptor / RestTemplate / Feign config / Http Headers)?
您需要在 http 请求标头中传递承载令牌。
我如何配置后端 Spring Boot 应用程序以使用它从上游 Spring Boot 应用程序接收到的经过身份验证的用户详细信息,以及我需要向后端 Spring Boot 应用程序添加哪些依赖项以促进这一点(org.keycloak:keycloak -spring-boot-starter 和 org.springframework.boot:spring-boot-starter-security)?
您需要在领域中添加一个新客户端,例如“后端客户端”并将其“访问类型”设置为“仅承载”。您将需要 'keycloak-spring-boot-starter' 和 'spring-boot-starter-security' 依赖项,也在您的添加 'keycloak-adapter-bom' 中。在您的 application.properties 中,您应该具有以下提到的属性
keycloak.realm =
keycloak.auth-server-url = your keycloak url
keycloak.ssl-required =external
keycloak.bearer-only=true
keycloak.resource =your client name
keycloak.credentials.secret= your secret key
keycloak.security-Constraints[0].authRoles[0] = user
keycloak.security-Constraints[0].securityCollections[0].patterns[0] = /*
keycloak.cors=true
我需要在 Keycloak 中为后端 Spring Boot App 配置什么吗?它是否应该在 Keycloak 中注册为机密/非公开客户端(例如 app-api)?
您需要创建一个新客户端,它应该注册为“仅承载”
你可以参考这个链接:https : //www.keycloak.org/docs/latest/securing_apps/#_spring_boot_adapter
添加回答
举报
