简体   繁体   English

如何成为SAML服务提供商

[英]How To Become a SAML Service Provider

My company currently develops a Java web application. 我公司目前正在开发Java Web应用程序。 A couple of our clients have internal SAML servers (identity providers?) and have requested that we integrate with them. 我们的几个客户有内部SAML服务器(身份提供商?),并要求我们与他们集成。 So recently I've been reading up on it and playing around with OpenAM. 所以最近我一直在阅读它并与OpenAM一起玩。 After about 3 days of this, I have a general understanding of it, but there are still some gaps in my knowledge. 大约3天后,我对它有一个大致的了解,但我的知识仍然存在一些差距。 My hope is that someone can clear this up for me. 我希望有人可以为我解决这个问题。

So here's how I imagine the workflow of a user logging in. 所以这就是我如何想象用户登录的工作流程。

Let's define our customers SAML server as https://their.samlserver.com . 让我们将客户SAML服务器定义为https://their.samlserver.com So a user comes to our web application for a resource that's protected. 因此,用户访问我们的Web应用程序以获取受保护的资源。 Let's say that URL is http://my.app.com/something . 假设网址是http://my.app.com/something

So if I'm correct, my.app.com is what SAML defines as a Service Provider . 所以,如果我是正确的, my.app.com就是SAML定义为服务提供商的东西 Our application realizes that this user needs to log in. We then present a page like this to the user... 我们的应用程序意识到该用户需要登录。然后我们向用户呈现这样的页面......

<script>JQuery Script to auto submit this form on ready</script>
<form method="post" action="https://their.samlserver.com/Post/Servlet">
    <input type="hidden" name="SAMLRequest" value="someBase64Data" />
    <input type="submit" value="Submit" />
</form>

And that someBase64Data should be base64 encoded version of this... 那个someBase64Data应该是base64编码版本的...

<samlp:AuthnRequest
  xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
  xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
  ID="identifier_1"
  Version="2.0"
  IssueInstant="2004-12-05T09:21:59Z"
  AssertionConsumerServiceIndex="0">
 <saml:Issuer>http://my.app.com</saml:Issuer>
 <samlp:NameIDPolicy
   AllowCreate="true"
   Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient"/>
</samlp:AuthnRequest>

So my first couple questions. 所以我的第一对问题。

What is the ID value suppose to be? 假设的ID值是多少?

And why can I declare myself as an Issuer ? 为什么我可以宣布自己为发行人

Does the Identity Provider know about me? 身份提供商是否了解我? Maybe this is that Circle of trust I've been seeing on OpenAM . 也许这就是我在OpenAM上看到过的信任圈 And if it does know about me, how does it know about me and what does it need to know? 如果它确实了解我,它如何了解我以及它需要知道什么?

So after the user is forwarded that page, they are taken to a page provided by the IDP https://their.samlserver.com . 因此,在用户转发该页面后,他们将被带到IDP https://their.samlserver.com提供的页面。 They authenticate on that page and the IDP does it's magic to validate the authentication and look up the user. 他们在该页面上进行身份验证,IDP可以验证身份验证并查找用户。 After the authentication is successful, the IDP sends back a <samlp:Response> defined here . 身份验证成功后,IDP会发回此处定义的<samlp:Response>

A few more questions. 还有一些问题。

First, how does the <samlp:Response> get back to my web application so I can check it? 首先, <samlp:Response>如何回到我的Web应用程序,以便检查它?

And what should I be looking for in that response to validate that it was successful? 我应该在该回复中寻找什么来验证它是否成功? What does a failure look like? 失败是什么样的?

We currently use the email address (LDAP) to identify users, so we'll probably grab that from the response and use that in the same way we do now. 我们目前使用电子邮件地址(LDAP)来识别用户,因此我们可能会从响应中获取并以与我们现在相同的方式使用它。 Anything else I should be mindful of in that response? 还有什么我应该注意的回应?

So now that we've checked that response for validity, we can grant the user a session like we do currently. 所以现在我们已经检查了有效性的响应,我们可以向用户授予像我们当前那样的会话。 But when they want to log out, is there a workflow for that? 但是当他们想要注销时,是否有工作流程? Do I have to notify the IDP that the user has left? 我是否必须通知IDP该用户已离开?

And finally, there are a couple of topics that have been thrown around in my reading and I'm not sure how they fit into this workflow. 最后,在我的阅读中有几个主题被抛出,我不确定它们如何适应这个工作流程。 They are Circle of trust , Tokens , and Artifacts . 它们是信任圈 ,代工件

Thanks for any help everyone. 感谢大家的帮助。 I've found a lot of information in the last couple days, and it's possible that I could piece them together after a bit more playing. 我在过去的几天里发现了很多信息,而且我可能会在玩完一段时间之后把它们拼凑起来。 But I have yet to find a straightforward "Here's the Post" workflow article yet. 但我还没有找到一个直截了当的“这是帖子”工作流程文章。 Maybe that's because I'm wrong on how this works. 也许那是因为我对这是如何工作的错了。 Maybe it's because this isn't that popular. 也许是因为这不是那么受欢迎。 But I really wanted to make sure that I got the workflow so I didn't miss a crucial step in something as important as user authentication. 但我真的想确保我得到了工作流程,所以我没有错过与用户身份验证同等重要的关键步骤。

In response to your specific questions: 回答您的具体问题:

1.) What is the "ID" value supposed to be? 1.)应该是什么“ID”值?

  • This should be a unique identifier for the SAML request. 这应该是SAML请求的唯一标识符。 The SAML 2.0 specification states that it's really implementation specific how this is done, but makes the following recommendations: SAML 2.0规范指出它是如何实现特定于实现的,但提出以下建议:

The mechanism by which a SAML system entity ensures that the identifier is unique is left to the implementation. SAML系统实体确保标识符唯一的机制留给实现。 In the case that a random or pseudorandom technique is employed, the probability of two randomly chosen identifiers being identical MUST be less than or equal to 2 ^ -128 and SHOULD be less than or equal to 2 ^-160 in length. 在采用随机或伪随机技术的情况下,两个随机选择的标识符相同的概率必须小于或等于2 ^ -128并且应该长度小于或等于2 ^ -160。 This requirement MAY be met by encoding a randomly chosen value between 128 and 160 bits in length. 可以通过编码长度为128到160位的随机选择值来满足此要求。

2.) How does the IdP know about you? 2.)IdP如何了解您?

  • Your SP needs to be registered with the IdP. 您的SP需要在IdP中注册。 To accomplish this, the SAML specification defines a format for "SAML Metadata" which tells the IdP where your SAML receivers are, what your certificates are, attributes you exchange, etc. OpenAM likely dictates some minimum requirements for configuring a trusted SP. 为实现此目的,SAML规范定义了“SAML元数据”的格式,该格式告诉IdP您的SAML接收器在哪里,您的证书是什么,您交换的属性等等.OpenAM可能规定了配置可信SP的一些最低要求。 This varies in each product. 每种产品都有所不同。

3.) Where's the Response go, and what to check? 3.)响应在哪里,以及检查什么?

  • The Response will go to your Assertion Consumer Service (ACS) URL usually defined in the SAML Metadata you exchange from your SP with the IdP for initial setup. 响应将转到您通常使用IdP进行初始设置从您的SP交换的SAML元数据中定义的断言消费者服务(ACS)URL。 When you receive a SAML Response, you need to check many things - but most importantly, the SAML Status code should be "success", the inResponseTo ID's should match the request's sent ones and you must validate the digital signature on the Assertion. 当您收到SAML响应时,您需要检查很多内容 - 但最重要的是,SAML状态代码应该是“成功”,inResponseTo ID应该与请求的已发送ID匹配,并且您必须验证断言上的数字签名。 For that, you'll need to trust the IdP's public verification certificate, and you'll probably also want to do revocation checking. 为此,您需要信任IdP的公共验证证书,并且您可能还想要进行撤销检查。

4.) What about Logout? 4.)退出怎么样?

  • SAML 2.0 also defines a profile for Single LogOut (SLO). SAML 2.0还定义了Single LogOut(SLO)的配置文件。 This will not only log you out of the SP, but also the IdP and potentially any other SP's you've established a session with. 这不仅会让您退出SP,还会使您与IdP以及您与之建立会话的任何其他SP一起登录。 It has a similar request/response flow as Single Sign-On (SSO), and thus similar things to set up and check (status codes, signatures, etc.). 它具有与单点登录(SSO)类似的请求/响应流程,因此具有类似的设置和检查功能(状态代码,签名等)。

So in short - this can be quite complex to implement from scratch. 简而言之 - 从头开始​​实施这一点非常复杂。 It's best to use tried & true libraries and/or products like Ian suggests. 最好使用Ian建议的经过验证的库和/或产品。 Companies like his have invested hundreds of hours of developer time to implement according to the spec and test interoperability with other vendors. 像他这样的公司已经投入了数百小时的开发时间来根据规范和测试与其他供应商的互操作性来实施。

If you're just trying to set a single Java application up as a Service Provider, you should consider using a Fedlet from either Oracle (as a standalone ) or ForgeRock ( bundled with OpenAM ). 如果您只是尝试将单个Java应用程序设置为服务提供者,则应考虑使用来自Oracle (作为独立)或ForgeRock (与OpenAM捆绑在一起)的Fedlet。 The ForgeRock Fedlet has some issues interacting with Shibboleth 2.2.1 as an Identity Provider, but I find it to be somewhat simpler to configure and more informative. ForgeRock Fedlet有一些与Shibboleth 2.2.1作为身份提供者交互的问题,但我发现配置起来更简单,信息更丰富。

Each has explicit instructions contained in the README to help you deploy. 每个都有自述文件中包含的显式指令,以帮助您进行部署。 Once the Fedlet is configured and communicating with the IDP, the success page shows you all the code you need to integrate federated SSO into your application. 配置Fedlet并与IDP通信后,成功页面将显示将联合SSO集成到应用程序中所需的所有代码。 It does the background work of sending and receiving AuthnRequests and Responses. 它执行发送和接收AuthnRequests和响应的后台工作。

Scott's answer responds quite well to the questions you had, but I think that trying to write code on your own that generates the SAML is reinventing the wheel. 斯科特的回答很好地回答了你的问题,但我认为尝试自己编写生成SAML的代码正在重新发明轮子。 The Fedlet was designed with precisely this use case in mind. Fedlet的设计正是考虑到这个用例。

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

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