Springboot Keycloak 集成
发布于: 刚刚
如果集成外部的 spring security 则不需要在配置里配置 节点了 security-constraints
这部分拦截规则配置在 spring security 中
keycloak:
# enabled: false
auth-server-url: http://10.31.203.72:8080/auth
credentials:
secret: 185018d8-8339-4b0e-b6cc-31d148ababa4
# principal-attribute: preferred_username
realm: testrealm
resource: testrealmclientid72
# ssl-required: external
#默认false,如果为true则检验用户级别权限角色,false则检验realm级别权限
# use-resource-role-mappings: true
# cors: true
# autodetect-bearer-only: true
security-constraints:
- authRoles:
- MYSELF_ROLE_CUSTOMER
securityCollections:
- name: all
patterns:
- /*
# - name: customer
# patterns:
# - /test/*
复制代码
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin -->
<!-- <dependency>-->
<!-- <groupId>org.sonarsource.scanner.maven</groupId>-->
<!-- <artifactId>sonar-maven-plugin</artifactId>-->
<!-- <version>3.8.0.2131</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-test</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>15.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
复制代码
划线
评论
复制
发布于: 刚刚阅读数: 4
版权声明: 本文为 InfoQ 作者【消失的子弹】的原创文章。
原文链接:【http://xie.infoq.cn/article/2c7f6e53ebbe1feb03410ffb5】。文章转载请联系作者。
消失的子弹
关注
还未添加个人签名 2017.10.11 加入
还未添加个人简介
评论