我正在尝试通过RelyingPartyRegistrationRepository
使用 spring security 5.3 配置多个 idp 这是我的 application.yaml 配置
spring:
security:
saml2:
relyingparty:
registration:
idpokta:
identityprovider:
entity-id: http://<url>
sso-url: https://<url>
verification:
credentials:
- certificate-location: "classpath:saml/okta.cert"
signing:
credentials:
certificate: |
-----BEGIN CERTIFICATE-----
MIIDpDCC...
-----END CERTIFICATE-----
private-key: |
-----BEGIN PRIVATE KEY-----
MIIEvQIBA....
-----END PRIVATE KEY-----
idponelogin:
identityprovider:
entity-id: https://<url>
sso-url: https://<url>
verification:
credentials:
- certificate-location: "classpath:saml/onelogin.cert"
signing:
credentials:
certificate: |
-----BEGIN CERTIFICATE-----
MIID/z...
-----END CERTIFICATE-----
private-key: |
-----BEGIN PRIVATE KEY-----
MIpoi...
-----END PRIVATE KEY-----
我的登录控制器定义如下:
@Controller
public class LoginController {
private final RelyingPartyRegistrationRepository relyingParties;
// ...
@GetMapping("/login")
public void login(HttpServletRequest request, HttpServletResponse response) throws IOException {
String registrationId = request.getParameter("idp");
RelyingPartyRegistration relyingParty = this.relyingParties
.findByRegistrationId(registrationId);
if (relyingParty == null) {
response.setStatus(401);
} else {
response.sendRedirect("/saml2/authenticate/" + registrationId);
}
}
问题
我的relyingParty 有提供程序的详细信息,但我认为myassertionConsumerServiceUrl
默认为{baseUrl}/login/saml2/sso/{registrationId}
并且my localEntityIdTemplate
= {baseUrl}/saml2/service-provider-metadata/{registrationId}` 的事实导致了它的问题。如何在我的 yaml 文件中添加 sp 信息?还是我这样做完全错了?