如何使钥匙斗篷与嵌入式码头一起工作?

时间:2019-12-16 11:03:06

标签: java jax-rs keycloak jersey-2.0 embedded-jetty

您好,我刚刚尝试过IAM的密钥斗篷,这对我来说似乎是个很棒的工具,但我似乎无法弄清的一件事是如何将其与当前运行的JAX-rs Web服务集成在一起就我搜索的内容而言,嵌入式Jetty服务器不存在密钥隐藏客户端适配器,而Jetty 9.x适配器似乎仅适用于Jetty独立(非嵌入式)服务器。这是否意味着我必须通过实现ContaineRequestFilter类并分析请求标头并利用令牌自省端点进行资源服务器授权来实现自己的客户端适配器?这是否是所有其他客户端适配器的工作方式或其他方式?

1 个答案:

答案 0 :(得分:1)

github上有两个有趣的项目,都使用Spring Boot:

https://github.com/Baeldung/spring-security-oauth/tree/master/oauth-sso/sso-authorization-server

此处记录:https://www.baeldung.com/keycloak-embedded-in-spring-boot-app

如果您希望Jetty作为嵌入式Web服务器,请更改 pom.xml

排除tomcat

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

添加码头

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
    <scope>provided</scope>
</dependency>

这个项目也很有趣:https://github.com/thomasdarimont/embedded-spring-boot-keycloak-server