当前位置: 首页 > 知识库问答 >
问题:

Spring SAML发送错误的AuthNRequest

汪欣德
2023-03-14
@Bean
    public MetadataGenerator metadataGenerator() {
        MetadataGenerator metadataGenerator = new MetadataGenerator();
        metadataGenerator.setEntityId(env.getProperty("saml.entity.id"));
        metadataGenerator.setExtendedMetadata(extendedMetadata());
        metadataGenerator.setIncludeDiscoveryExtension(false);
        metadataGenerator.setKeyManager(keyManager());
        return metadataGenerator;
    }

@Bean
    @Qualifier("idp-ssocircle")
    public ExtendedMetadataDelegate ssoCircleExtendedMetadataProvider() throws MetadataProviderException {
        String idpSSOCircleMetadataURL = env.getProperty("saml.provider.url");
        HTTPMetadataProvider httpMetadataProvider = new HTTPMetadataProvider(this.backgroundTaskTimer, httpClient(),
                idpSSOCircleMetadataURL);
        httpMetadataProvider.setParserPool(parserPool());
        ExtendedMetadataDelegate extendedMetadataDelegate = new ExtendedMetadataDelegate(httpMetadataProvider,
                extendedMetadata());
        extendedMetadataDelegate.setMetadataTrustCheck(true);
        extendedMetadataDelegate.setMetadataRequireSignature(false);
        backgroundTaskTimer.purge();
        return extendedMetadataDelegate;
    }
saml.entity.id=urn:saml2:test:s
saml.provider.url=https://fedsvc-stage.pwc.com/ofiss/FederationMetadata/2007-06/FederationMetadata.xml

现在我正在尝试访问SAML身份验证背后的url-

http://mysso.com:8080/sso-self/auth/login

用户get重定向到他输入凭据的IDP,在完整身份验证成功后,用户get重定向回-http://localhost:8080/sso-self/saml/sso,带有saml响应,但我在浏览器上得到404,控制台上出现以下错误-

org.opensaml.common.SAMLException: InResponseToField of the Response doesn't correspond to sent message a330ei589j3e99ee10d8a55bghc518i

我可以看到的问题是,当第一个请求来自域名mysso.com时,消息是从两个不同的会话存储和检索的,但响应返回到本地主机

<?xml version="1.0" encoding="UTF-8"?><saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" AssertionConsumerServiceURL="http://localhost:8080/madison-sso-self/saml/SSO" Destination="https://fedsvc-stage.pwc.com/ofiss/" ForceAuthn="false" ID="a345ia5236e6hc2g48ea13fcf4386h7" IsPassive="false" IssueInstant="2018-12-18T07:46:41.812Z" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Version="2.0">
   <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">urn:saml2:test:s</saml2:Issuer>
</saml2p:AuthnRequest>

如果你需要更多的信息来解决问题,请回复。提前谢了。

共有1个答案

邵浩大
2023-03-14

您可以使用SAMLContextProviderLB来解决此问题。请用您的服务器URL替换下面配置中的值。

@Bean
public SAMLContextProviderLB contextProvider() {
  SAMLContextProviderLB samlContextProviderLB = new SAMLContextProviderLB();
  samlContextProviderLB.setScheme("https");
  samlContextProviderLB.setServerName("www.myserver.com");
  samlContextProviderLB.setServerPort(443);
  samlContextProviderLB.setContextPath("/spring-security-saml2-sample");
  samlContextProviderLB.setStorageFactory(new EmptyStorageFactory());
  return samlContextProviderLB;
}

上面的配置将使用https://www.myserver.com/spring-security-saml2-sample/SAML/sso从SAML服务提供者重定向。

samlContextProviderLB.setStorageFactory(new EmptyStorageFactory());

上面的代码行将有助于解决多会话问题。

 类似资料:
  • 我有一个使用spring security和mvc框架开发的门户应用程序。此门户应用程序连接到IDP(使用Spring security和Spring saml开发)进行身份验证。如果用户身份验证成功,用户将被导航到主页,其中为外部应用程序提供了多个链接……当用户单击应用程序链接时,用户应成功导航到相应的应用程序,而无需质疑登录页面。 其他应用程序是使用strut和Spring Security开

  • 问题内容: 嗨,我在下面的脚本中遇到了问题。我认为问题在于需要通过AJAX发送到php的数据。 jQuery的 并且,PHP 但是,如果我这样做 并改变这个 脚本工作正常。我需要做些什么才能使以上两个脚本都能正常工作?提前致谢。 问题答案: 我将我的评论作为答案。 除了使用已弃用的jQuery API外,其他人没有指出的是以下内容: 您在下一行中正在做什么: 是您向服务器保证HTTP实体将是JSO

  • 控制器(我忽略了导入) 下面是我在控制器中引用的相关html页面。您可以假设每一个服务和存储库都正常工作,并完成了它的工作。 这是确认页面。这里有点不对劲。插入到表单的隐藏输入框中的数据不会被提交: 扬尼克

  • 本文向大家介绍通过Email发送PHP错误的方法,包括了通过Email发送PHP错误的方法的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了通过Email发送PHP错误的方法。分享给大家供大家参考。具体实现方法如下: 希望本文所述对大家的php程序设计有所帮助。

  • 我正在使用postman查看Twilio中发送消息api的响应格式。我使用的Api是https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages。我已经输入了基本的身份验证参数(帐户\u Sid和AuthToken作为用户名和密码),json请求格式为 但我得到的错误是21603,上面写着“需要一个‘发件人’电话号码”。你能告诉我

  • 如何解决这个SMTP错误问题?当我发送邮件时,我会遇到这个错误信息。使用本地系统发送邮件不是问题。有人知道这个问题的解决方法吗? System.Net.Mail.SMTPException:SMTP服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.5.1需要身份验证。 在System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode st