我编写了一个基于OIOSAML的SP启动Web SSO场景的简单系统。为了测试系统,我将其部署在远程主机上。
但是AssertionConsumerServiceURL
,我指定了网址,Shibboleth idP(基于Shibboleth的idP)应该返回的答案不会被调用。
SAMLAssertionConsumer
- 只是一个简单的servlet,如下所示:
@WebServlet("/saml/consumer")
public class SAMLAssertionConsumer extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println(new Date() + " incoming AuthResponse");
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Yes, it worked");
System.out.println(new Date() + " incoming AuthResponse");
}
}
首先,我只需要确保响应来了。
我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
metadata-complete="false"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<display-name>OIOSAML-J</display-name>
<listener>
<listener-class>dk.itst.oiosaml.sp.service.session.SessionDestroyListener</listener-class>
</listener>
<servlet>
<servlet-name>SAMLDispatcherServlet</servlet-name>
<servlet-class>dk.itst.oiosaml.sp.service.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SAMLDispatcherServlet</servlet-name>
<url-pattern>/saml/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>dk.itst.oiosaml.sp.service.SPFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>/sp/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
我的oiosaml-sp.properties:
# Properties used by oiosaml-j
# Reference to the location of the certificate used for signing SAML documents with - relative to ${oiosaml.home}
oiosaml-sp.certificate.location=./certificate/keystore
# Opaque/encrypted password to the certificate used for signing SAML documents
oiosaml-sp.certificate.password=some_password
# Required authentication level. 2=password, 3=certificate
oiosaml-sp.assurancelevel=2
# Name of the meta data file for the current service provider - overrides setting in brs-common.properties
common.saml2.metadata.sp.filename=SPMetadata.xml
# URI References to the current service provider
oiosaml-sp.uri.home=
# Whether to validate server certificates. Set to false in production.
# Used for artifact resolution.
oiosaml-sp.resolve.ignorecert=true
# Artifact resolution username and password. Only used the artifact profile is active.
oiosaml-sp.resolve.username=rolf.trifork.com
oiosaml-sp.resolve.password=rolf.trifork.com
生成AuthnRequest
:
<?xml version="1.0" encoding="UTF-8"?>
<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
AssertionConsumerServiceURL="http://ip-of-remote-system-here:8080/saml/consumer"
Destination="http://ip-of-identity-provider-here/idp/profile/SAML2/Redirect/SSO" ForceAuthn="false"
ID="_31e...341d322d1d" IsPassive="false"
IssueInstant="2014-07-11T10:24:43.852Z"
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">http://ip-of-remote-system-here:8080</saml2:Issuer>
</saml2p:AuthnRequest>
有一些JSP页面private.jsp,我向它发出请求:
http://ip-of-remote-system-here:8080/sp/private.jsp
在此请求之后,我重定向到身份提供者的登录页面:
http://ip-of-identity-provider-here/idp/Authn/CommonLogin
输入一对登录名/密码,然后输入 。打开包含一些常见错误说明的页面:
http://ip-of-identity-provider-here/idp/Authn/UsernamePasswordLogin
错误
请求处理时发生错误。
不起作用,我的servlet SAMLAssertionConsumer
,控制台很清楚。但是,如果我直接向我的servlet SAMLAssertionConsumer
发出请求:
http://ip-of-remote-system-here:8080/saml/consumer
然后它有效。当然。
我想知道如何正确配置断言使用者服务。这是SP元数据的一部分,我在其中指定了断言消费者。
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:esia="urn:esia:shibboleth:2.0:mdext" entityID="http://ip-of-remote-system-here:8080">
...
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="http://ip-of-remote-system-here:8080/saml/consumer" ResponseLocation="http://ip-of-remote-system-here:8080/saml/consumer"/>
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://ip-of-remote-system-here:8080/saml/consumer" index="0" isDefault="true"/>
我将非常感谢这些信息。谢谢大家。
答案 0 :(得分:0)
问题不同了。使用了错误的密钥库。现在一切都好。
最初,我假设entityID
属性必须引用属性Location
中指定的域名。但事实并非如此。它必须是唯一的,最好使用域名。
UnderstandingShibboleth, EntityNaming:
在SAML中使用Shibboleth身份和服务提供商 部署,因此,它们被分配了一个称为的唯一名称 “ENTITYID”。
Metadata for the OASIS Security Assertion Markup Language (SAML)V2.0, 2.3.2 Element :
entityID
[必填] -Specifies the unique identifier of the SAML entity whose metadata is described by the element's contents.
UnderstandingShibboleth, EntityNaming:
强烈建议不要使用服务器的物理主机名 将Shibboleth作为
entityID
运行。随着时间的推移,事情就会发生变化 并且该部署可能并不总是存在于同一个框中。此外,Shibboleth可能有多个逻辑部署 在单个物理服务器上,每个都需要它们自己的唯一
entityID
,因此使用服务器名称不会超出单个名称 之一。
在沙箱中可以使用物理地址。