程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Spring SAML2 Saml2WebSsoAuthenticationFilter 自定义 AuthenticationSuccessHandler大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Spring SAML2 Saml2WebSsoAuthenticationFilter 自定义 AuthenticationsuccessHandler?

开发过程中遇到Spring SAML2 Saml2WebSsoAuthenticationFilter 自定义 AuthenticationsuccessHandler的问题如何解决?下面主要结合日常开发的经验,给出你关于Spring SAML2 Saml2WebSsoAuthenticationFilter 自定义 AuthenticationsuccessHandler的解决方法建议,希望对你解决Spring SAML2 Saml2WebSsoAuthenticationFilter 自定义 AuthenticationsuccessHandler有所启发或帮助;

我使用 Spring Security v5.5.1 SAML2 代码来支持 SAML。我有一个使用旧版 Spring 安全扩展的可行解决方案,但我正在“升级”。

我已经启动了 SP 和 IDP 启动的流程,但我不知道如何配置成功处理程序重定向 URL。默认为“/”。我不明白如何访问 Saml2WebSsoAuthenticationFilter 和/或 SavedrequestAwareAuthenticationsuccessHandler 以覆盖 URL。

我在 IDP 上设置了默认值 RelayState,它确实与断言一起发送,但 Spring 似乎没有使用它。

此外,使用较旧的扩展程序,我可以将 SAML 请求存储在数据库中,并在响应到来时检索它,因为我的应用程序不使用会话。我还没有在这里找到同样的方法。

以下是从我找到的文档和示例中收集的我的身份验证提供者和中继方注册:

OpenSaml4AuthenticationProvIDer authenticationProvIDer = new openSaml4AuthenticationProvIDer();
authenticationProvIDer.setAssertionValIDator( OpenSaml4AuthenticationProvIDer.createDefaultAssertionValIDator( assertionToken -> {
                    Map<String,Object> params = new HashMap<>();
                    params.put( CLOCK_SKEW,Duration.ofminutes(10).toMillis());

                    String recipIEnt = assertionToken.getToken().getRelyingPartyRegistration().getAssertionConsumerserviceLOCATIOn();
                    params.put( SAML2AssertionValIDationParameters.SC_VALID_RECIPIENTS,Collections.singleton(recipIEnt));

                    String audIEnce = assertionToken.getToken().getRelyingPartyRegistration().getAssertionConsumerserviceLOCATIOn();
                    params.put( SAML2AssertionValIDationParameters.COND_VALID_AUDIENCES,Collections.singleton( "blah"));

                    return new ValIDationContext( params);
                })
        );

Converter<httpServletrequest,RelyingPartyRegistration> relyingPartyRegistrationResolver =
        new DefaultRelyingPartyRegistrationResolver( relyingPartyRegistrationRepository);

Saml2MetadataFilter filter = new Saml2MetadataFilter(
                relyingPartyRegistrationResolver,new openSamlMetadataResolver());

http
    .sessionManagement()
    .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
    .and()
    .authorizerequests()
    .antMatchers( "/saml2/**").permitAll()
    .antMatchers( "/login/**").permitAll()
    .and()
    .saml2Login( saml2 -> saml2.authenticationManager( new ProvIDeRMANager( authenticationProvIDer)))
    .addFilterBefore( filter,Saml2WebSsoAuthenticationFilter.class);
RelyingPartyRegistration registration = RelyingPartyRegistration
        .withRegistrationID("blah")
        .assertionConsumerserviceLOCATIOn( getAssertionRecipIEnt( environment,"blah"))
        .signingX509Credentials( c -> c.add( credentialSp))
        .decryptionX509Credentials( c -> c.add( decryptSp))
        .asserTingPartyDetails(party -> party
            .entityID("blah")
            .singleSignOnserviceLOCATIOn("https://sso.stuff/samlstuff")
            .wantAuthnrequestsSigned( falsE)
            .verificationX509Credentials( c -> c.add( credential))
        )
        .build();

我想我可以以某种方式像以前一样做,但是对于提供的所有文档,很难理解其中的大部分内容。

谢谢!

解决方法

试试这样对我有用的东西。 .saml2Login( saml2 -> {saml2.authenticationManager( new ProvideRMANager( authenticationProvider); saml2.defaultsuccessUrl("url") }))

大佬总结

以上是大佬教程为你收集整理的Spring SAML2 Saml2WebSsoAuthenticationFilter 自定义 AuthenticationSuccessHandler全部内容,希望文章能够帮你解决Spring SAML2 Saml2WebSsoAuthenticationFilter 自定义 AuthenticationSuccessHandler所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。