响应没有任何可以通过主题验证的有效断言

Response doesn't have any valid assertion which would pass subject validation

我对 SAML 和 ADFS 完全陌生。我试着用谷歌搜索我的错误,但遗憾的是没有得到任何结果。我一直在尝试设置 Spring SAML 和 ADFS,这样我就可以按照 this guide 进行单点登录工作,似乎我已经接近尾声了,但我遇到了以下错误: 响应没有任何可以通过主题验证的有效断言

轨迹轨迹:

[#|2015-10-29T08:03:43.334+0100|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=1689;_ThreadName=Thread-2;|- AuthNResponse;FAILURE;fe80:0:0:0:e1fd:739e:9d4e:8883%14;https://nkr-beh1:18181/saml/saml/metadata;http://NKR-AD.adm.kulturrad.no/adfs/services/trust;;;org.opensaml.common.SAMLException: Response doesn't have any valid assertion which would pass subject validation
at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:229)
at org.springframework.security.saml.SAMLAuthenticationProvider.authenticate(SAMLAuthenticationProvider.java:82)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
at org.springframework.security.saml.SAMLProcessingFilter.attemptAuthentication(SAMLProcessingFilter.java:84)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:195)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.saml.metadata.MetadataGeneratorFilter.doFilter(MetadataGeneratorFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:745)

我检查了代码,它应该从响应 (ADFS) 中获取断言,如果它为空,它会抛出错误。我想这意味着我的 ADFS 丢失了一些东西,或者我误解了什么是断言?

首先,您应该进行 Fiddler 跟踪并查看 AD FS 是否成功发布了令牌。或者,您可以在 AD FS 端启用审核以查看颁发了哪些令牌(如果有)。

有关审核说明,请参阅此处 https://technet.microsoft.com/en-us/library/adfs2-troubleshooting-configuring-computers(WS.10).aspx#bkmk_ConfigureAuditing

然后安全事件日志和 AD FS 事件日志应该确认颁发令牌是否有错误或是否已成功颁发。

查看此处了解有关审查 Fiddler 的一些详细信息。它是为 wsfed 编写的,但对 SAML 也有帮助。 http://social.technet.microsoft.com/wiki/contents/articles/3286.aspx

此插件也可用于更好地查看令牌。可能比使用 textwizard 进行 base64/deflatedsaml 解码更容易。 http://social.technet.microsoft.com/wiki/contents/articles/3590.fiddler-inspector-for-federation-messages.aspx

Fiddler 将干扰 Windows 集成身份验证,除非您遵循此 link 并禁用 AD FS 上的扩展保护。 http://social.technet.microsoft.com/wiki/contents/articles/ad-fs-2-0-continuously-prompted-for-credentials-while-using-fiddler-web-debugger.aspx

如果你有 2012R2,你应该

Set-ADFSProperties -ExtendedProtectionTokenCheck None 

如果您的应用程序提供了加密证书并且 AD FS 正在发送加密断言,Fiddler 将无济于事。在这种情况下,AD FS 安全日志和调试日志更易于使用以准确查看发送的内容。

此处的目标是查看断言和主题元素。然后检查验证失败的原因。

您可以在此处查看示例断言 https://rnd.feide.no/samlexample/simplesamlphp_saml_2_0_authentication_response/。您需要查看 AD FS 是否成功颁发了令牌(检查状态为成功而非响应者)以及符合您的应用程序验证检查的主题。

我 运行 遇到与 Srping 安全 SAML 相同的问题,解决方案是当您创建 MetadataGenerator Bean 时,实体 ID 集应与 Idp Provider 中的受众限制(或类似字段)完全匹配,我已经使用Okta 作为 Idp 提供者,因此受众限制是要正确配置的字段

当我收到此错误时,我的日志中还包含以下消息:

Decryption of received assertion failed, assertion will be skipped

在 DEBUG 级别(来自 class WebSSOProfileConsumerImpl),并且:

Error decrypting the encrypted data element
org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size

处于错误级别。

并且 SAML 响应包含:

<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />

请注意,256 位 AES 加密需要 JCE 无限强度 jar。