如何为端点 /saml2/authenticate/{registrationId} spring-security-saml2 配置 {baseUrl}?

问题描述 投票:0回答:1

我正在尝试实施 saml2 SSO。
我的项目使用网关(端口 8090)。身份验证逻辑位于第二个服务(端口 8080)中,但我希望所有请求都通过网关

我尝试实现这个,但最终重定向到第二个服务 localhost:8080/saml2/authenticate/{registrationId}。 我认为问题在于调用身份提供者的服务(第二个)也必须接受请求,而不是将它们委托给网关。
也许有一些解决方法可以使此请求通过网关?

此外,我无法将此逻辑传输到网关,因为目前不支持反应式 SAML。

我几乎没有安全方面的工作经验(尤其是 SAML)。 所以我将不胜感激任何帮助!

依赖关系:
- 网关

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
    <version>3.0.4</version>
</dependency>

- 第二个服务中的 SAML 依赖项

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-saml2-service-provider</artifactId>
    <version>5.5.2</version>
</dependency>
<dependency>
    <groupId>org.opensaml</groupId>
    <artifactId>opensaml-core</artifactId>
    <version>4.1.1</version>
</dependency>
<dependency>
    <groupId>org.opensaml</groupId>
    <artifactId>opensaml-saml-api</artifactId>
    <version>4.1.1</version>
</dependency>
<dependency>
    <groupId>org.opensaml</groupId>
    <artifactId>opensaml-saml-impl</artifactId>
    <version>4.1.1</version>
</dependency>
java spring saml-2.0 spring-cloud-gateway
1个回答
0
投票

最终我发现这可以通过 6 版本的 Spring 安全配置来完成。

https://github.com/spring-projects/spring-security/issues/8873

http.saml2Login(saml2 -> {                
    saml2.authenticationRequestUri("yourUrl")
};
© www.soinside.com 2019 - 2024. All rights reserved.