简体   繁体   English

如何通过有效的SAML 2.0断言登录?

[英]How to login throught a valid SAML 2.0 assertion?

I'm working on an Android project which has to strongly interact with a SSO Shibboleth authentication protected website. 我正在开发一个Android项目,该项目必须与SSO Shibboleth身份验证受保护的网站进行强烈交互。 I have, therefore, to create a Java class in order to make a valid SAML assertion and to login into the website. 因此,我必须创建一个Java类,以便进行有效的SAML声明并登录到网站。

I googled a lot, and I find this piece of code: http://blog.keksrolle.de/2010/07/27/how-to-create-a-valid-saml-2-0-assertion-with-opensaml-for-java.html In fact I discovered that it was not needed, since that I was able to get the SAML response through some HttpConnection requests. 我在Google上搜索了很多,然后发现了这段代码: http : //blog.keksrolle.de/2010/07/27/how-to-create-a-valid-saml-2-0-assertion-with-opensaml -for-java.html实际上,我发现不需要它,因为我能够通过一些HttpConnection请求获得SAML响应。

The code I wrote was able to perform steps 1-5 of this list: http://en.wikipedia.org/wiki/Security_Assertion_Markup_Language#The_SAML_Use_Case The last thing it does is getting the value of the SAMLResponse parameter, which is the base64 encoding of a element. 我编写的代码能够执行此列表的步骤1-5: http : //en.wikipedia.org/wiki/Security_Assertion_Markup_Language#The_SAML_Use_Case最后要做的就是获取SAMLResponse参数的值,该值是base64编码元素 Then it issues a POST request to the assertion consumer service. 然后,它向断言使用者服务发出POST请求。 Here the pseudo-code : 这里的伪代码

/* discover the IdP */
connect to the link (/idp/login/) which redirects to the form page (/Authn/UserPassword)
get cookies from the link in order to gain access to the form page
/* end */
/* get SAML response climbing the redirects */
set goTo var to the link of the form page
do {
    send POST data (+ cookies) to the goTo page
    get cookies of the new page and saves them with the others
    set goTo to connection.getHeaderField("Location");
} while (!(responseCode==200));
read the source of the last redirect 
get the specific SAMLResponse
/* end */
send it to website.com/Shibboleth.sso/SAML2/POST
get cookies, session data

But afterward the response of the server is a 500 error code, or an on page error code ("Something went wrong. Retry."). 但是之后,服务器的响应是500错误代码或页面错误代码(“发生错误。重试。”)。 In fact, I'm not able to gain the access to the session, even if I have a valid SAML assertion which I send (encoded) to the server. 实际上,即使我有一个有效的SAML断言(已发送(编码)到服务器),也无法访问该会话。 Is it a problem of session? 这是会议的问题吗? Once I issued the POST request, I supposed that the server reconized me via cookies (JSESSIONID) and via querystring (/home.do;jsessionid=XXXFAEC60AXXX7A7B9XXXAA9EXXXE71X.jvm2c), but I think that maybe something went totally wrong. 发出POST请求后,我以为服务器通过cookie(JSESSIONID)和查询字符串(/home.do;jsessionid=XXXFAEC60AXXX7A7B9XXXAA9EXXXE71X.jvm2c)协调了我,但我认为可能有些地方完全错了。

How can I login into a SAML authenticated website via Java? 如何通过Java登录经过SAML身份验证的网站?

Another (marginal) problem: I performed all the request without encryption (https). 另一个(边际)问题:我执行了所有请求而未加密(https)。 Can this be a problem from the point of view of security (packets sniffing etc)? 从安全角度(数据包嗅探等)来看,这可能是一个问题吗?

Unfortunately I can't picture what is your exact problem. 不幸的是,我无法想象您的确切问题是什么。 I can only redirect you to Shibboleth Web page , which can enlighten you in terms of shibboleth workflow. 我只能将您重定向到Shibboleth网页 ,它可以在shibboleth工作流程方面给您带来启发。 There is also documentation of SAML profiles (page 14 WB-SSO). 也有SAML配置文件的文档 (第14页WB-SSO)。 I found it helpfull during extending my application with Single Logout Profile 我发现在使用Single Logout Profile扩展我的应用程序期间它很有帮助

As for lack of https... it's a major security leak. 至于缺少https ...这是一个重大的安全漏洞。 The purpose of using Shibbolethh or WBSSO at all is to grant maximum protection to both resources and confident user information. 完全使用Shibbolethh或WBSSO的目的是为资源和可靠的用户信息提供最大的保护。 First of all you need secure login credential exchange with IdP. 首先,您需要与IdP进行安全的登录凭据交换。 Secondly, if someone sniff signed (and maybe even encrypted) assertion, which idp sends back to your application, he may not be able to obtain user information from it (due to encryption) but he can access your secured service for as long as assertion is valid (5 min, 15 min or even sevral hours - depends on IdP configuration) 其次,如果有人嗅到签名(甚至加密)的断言(idp发送回您的应用程序),则他可能无法从中获取用户信息(由于加密),但是只要断言,他就可以访问您的安全服务有效(5分钟,15分钟甚至几个小时-取决于IdP配置)

Edit 1: As for sample codes, check out Guanxi (Shibboleth implementation in Java), maybe you it will help you 编辑1:作为示例代码,请 (在Java中的Shibboleth实现),也许你会帮助你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM