使用Keycloak保护 organization 服务
将Spring Security和Keycloak 的JAR包添加到要保护的服务中
<dependencies>
<!-- OAuth2 Client dependency -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
</dependency>
<!-- OAuth2 Client dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>配置服务,以指向Keycloak服务器
定义能够谁能够访问服务
任何经过身份认证的用户都可以访问整个服务
通过特定角色保护服务
Last updated