我正在尝试创建 SAML 响应。构成断言的属性之一称为地址,属性值需要是在 XSD 中定义的自定义类型。如何向响应添加自定义属性值类型?
我在opensaml2.6上运行此代码
Element metadataRoot = document.getDocumentElement();
// Unmarshall
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot);
if (unmarshaller == null) {
System.out.println("Error receiving unmarshaller for this document.");
return;
}
Run Code Online (Sandbox Code Playgroud)
对于文件
<?xml version="1.0" encoding="UTF-8"?><saml2:EncryptedAssertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
Run Code Online (Sandbox Code Playgroud)
Unmarshaller返回a null,你能帮助我了解如何查找正确的标准Unmarshaller以及它在opensaml中是如何工作的?
我有一个Java Web应用程序.我想为我的应用程序实现SAML单点登录登录.我有这个GitHub onelogin程序来发送请求并获得响应.但它没有正常工作.我在那里创建了一个帐户.但我没有企业帐户.当我运行应用程序时,它将进入onelogin登录页面.我尝试登录,但它没有在响应中返回任何内容,表明我没有权限.如果我也提供了错误的凭据,则它不会给出任何SAML响应.
所以我决定创建一个断言并签名.
谢谢
更新1
<?xml version="1.0" encoding="UTF-8"?>
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
ID="123" InResponseTo="abc" IssueInstant="2014-11-21T17:13:42.872Z"
Version="2.0">
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0">
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">
user@example.com
</saml:NameID>
</saml:Subject>
<saml:AuthnStatement AuthnInstant="2014-11-21T17:13:42.899Z">
<saml:AuthnContext>
<saml:AuthnContextClassRef>
urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
</saml:Assertion>
</samlp:Response>
Run Code Online (Sandbox Code Playgroud) 我想处理Spring Security SAML.为此,我开始探索Spring Security SAML.一开始,我在SSOCircle创建了一个帐户.比我配置IDP元数据和生成SP元数据(4.2.2和4.2.3).在entityId我设定:
<bean id="metadataGeneratorFilter" class="org.springframework.security.saml.metadata.MetadataGeneratorFilter">
<constructor-arg>
<bean class="org.springframework.security.saml.metadata.MetadataGenerator">
<property name="entityId" value="http://idp.ssocircle.com"/>
</bean>
</constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)
当我开始申请时,我有:
Error occurred:
Reason: Unable to do Single Sign On or Federation.
Run Code Online (Sandbox Code Playgroud)
要么
Error occurred:
Reason: Unable to get AuthnRequest.
Run Code Online (Sandbox Code Playgroud)
如何配置Spring Security SAML?
我已经使用 Spring-SAML 扩展成功实现了 SSO 身份验证。我们支持 IDP 发起的 SSO 到我们的应用程序的主要要求。好吧,通过使用 spring-security-saml2-sample 中的配置,甚至 SP 启动的 SSO 流程也适用于我们。
问题:密钥库是否用于 IDP 发起的 SSO(如果元数据有证书)?如果不使用,我想从securityContext.xml 中删除密钥库配置。
注意:我们不需要 SP 发起的 SSO 和全局注销。我们使用 Okta 作为 IDP。
在处理基于 Apache Tomcat SAML 2.0 的单点登录 (SSO) 时,我遇到了 SAML 2.0 身份验证请求下名为“IsPassive”的属性。SAML 2.0 规范对此进行了如下介绍:
IsPassive [可选] 布尔值。如果为“true”,则身份提供者和用户代理本身不得明显地从请求者那里控制用户界面,并以明显的方式与演示者交互。如果未提供值,则默认值为“false”。
就单点登录场景而言,此定义最准确的含义或示例是什么?此属性是否与单点登录中的主动和被动配置文件有联系?
在我们的应用程序中,我们尝试升级到 Spring boot 2,我们使用 spring-security-saml2-core:1.0.4.RELEASE,在运行应用程序时,我们遇到以下异常。看起来,classpaath 上有两个 jar xmltooling-1.4.6和opensaml-core-3.3.0,它们具有相同的文件default-config.xml。在这种情况下,类加载器碰巧将opensaml-core-3.3.0放在xmltooling-1.4.6.jar 之前,并且default-config.xml加载错误
<ObjectProviders>
<ObjectProvider qualifiedName="xt:DEFAULT">
<BuilderClass className="org.opensaml.core.xml.schema.impl.XSAnyBuilder"/>
<MarshallingClass className="org.opensaml.core.xml.schema.impl.XSAnyMarshaller"/>
<UnmarshallingClass className="org.opensaml.core.xml.schema.impl.XSAnyUnmarshaller"/>
</ObjectProvider> </ObjectProviders>
java.lang.ClassCastException: org.opensaml.core.xml.schema.impl.XSAnyBuilder cannot be cast to org.opensaml.xml.XMLObjectBuilder
at org.opensaml.xml.XMLConfigurator.initializeObjectProviders(XMLConfigurator.java:236)
at org.opensaml.xml.XMLConfigurator.load(XMLConfigurator.java:182)
at org.opensaml.xml.XMLConfigurator.load(XMLConfigurator.java:166)
at org.opensaml.xml.XMLConfigurator.load(XMLConfigurator.java:143)
at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:203)
at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:186)
at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:92)
at org.opensaml.PaosBootstrap.bootstrap(PaosBootstrap.java:27)
at org.springframework.security.saml.SAMLBootstrap.postProcessBeanFactory(SAMLBootstrap.java:42).
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?请..
我有一个 Maven 多模块项目,在 saml2 场景中使用 spring boot 2.6.4 和 spring security。
据我所知,spring 使用 opensaml,更准确地说是 opensaml 4.1.1
我将此依赖项添加到我的 saml maven 模块的 pom 中:
<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>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-saml-impl</artifactId>
<version>4.1.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-security-api</artifactId>
<version>4.1.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-security-impl</artifactId>
<version>4.1.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-profile-api</artifactId>
<version>4.1.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion> …Run Code Online (Sandbox Code Playgroud) 使用OpenSAML 3时,必须首先opensaml-saml-impl使用以下代码行从工件加载组件:
InitializationService.initialize();
Run Code Online (Sandbox Code Playgroud)
这用于java.util.ServiceLoader加载任何实现的类型Initializer.
当我编写测试并运行它时mvn integration-test,这工作正常,我可以看到所有内容都已加载:
Assert.assertTrue(
XMLObjectProviderRegistrySupport
.getUnmarshallerFactory()
.getUnmarshallers()
.size() > 400);
Run Code Online (Sandbox Code Playgroud)
但是,我的项目使用maven-shade-plugin.如果我将代码打包到超级jar中,则上述条件不正确:
mvn package
java -jar /path/to/my.jar
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我观察到只有9 unmarshallers已加载(这些opensaml-core,而不是那些在opensaml-saml-impl然而,当我看的输出.mvn package我可以看到,类型都包含在阴影罐子:
[INFO] Including org.opensaml:opensaml-saml-impl:jar:3.2.0 in the shaded jar.
[INFO] Including org.opensaml:opensaml-profile-api:jar:3.2.0 in the shaded jar.
[INFO] Including org.opensaml:opensaml-messaging-api:jar:3.2.0 in the shaded jar.
[INFO] Including org.opensaml:opensaml-saml-api:jar:3.2.0 in the shaded jar.
[INFO] Including org.opensaml:opensaml-xmlsec-api:jar:3.2.0 in the shaded jar.
[INFO] Including …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Spring Boot SAML2 + Spring Session 来保护我的 Web 应用程序(将部署在 K8S 上)。没有 spring-session-data-rest 或 spring-session-hazelcast 一切都很好。它可以通过 Okta 进行身份验证,并在身份验证后重定向回所请求的页面。另外,我可以使用 opensaml3 或 opensaml4。
但是,当我尝试使用 spring-session-data-rest 或 spring-session-hazelcast (只有 1 个实例,还没有集群)时,它不会重定向回请求的页面。此外,opensaml4 也会失败,并出现异常:“响应包含 InResponseTo 属性 [],但未找到已保存的身份验证请求”。有人提到 opensaml3 即将停产,所以我想让它与 opensaml4 一起使用。
这是一个示例应用程序来演示我的案例https://github.com/simonckw/redis-saml2/tree/redis。我错过了什么吗?有人有这个设置的工作样本吗?非常感谢您的帮助。
ps 我已经追踪到 HttpSessionRequestCache.java,从 SavedRequestAwareWarpper.java 调用。如果没有 spring-session-data-rest 或 spring-session-hazelcast,可以检索保存的请求,但在启用 spring-session-data-rest 或 spring-session-hazelcast 时则无法检索。在我看来,InResponseTo 异常也可能与之相关。我的 Redis 设置应该没问题。这是写入 Redis 的会话数据:
127.0.0.1:6379> hkeys 弹簧:会话:会话:7c1858d1-0ea7-4a7a-8523-2abf89137771
127.0.0.1:6379> hkeys 弹簧:会话:会话:58a584d3-625e-4e0a-bef5-3aaff485ad93
spring-security opensaml spring-saml spring-session spring-security-saml2
opensaml ×10
java ×5
saml-2.0 ×3
spring-saml ×3
maven ×2
spring-boot ×2
marshalling ×1
null ×1
saml ×1
spring ×1