首页 > 其他分享 >SAML-based SSO Flow

SAML-based SSO Flow

时间:2023-09-08 20:45:44浏览次数:50  
标签:based Service SP Flow SSO user HTTP example

概念

SAML: Security Assertion Markup Language
SSO: single sign-on
SP: Service Provider
IdP: Identity provider
UA:User Agent (Browser)

SP-Initiated SSO Flow

The processing is as follows:

1

The user attempts to access a resource on sp.example.com. The user does not have a valid logon session (i.e. security context) on this site. The SP saves the requested resource URL in local state information that can be saved across the web SSO exchange.

2

The SP sends an HTTP redirect response to the browser (HTTP status 302 or 303). The Location HTTP header contains the destination URI of the Sign-On Service at the identity provider together with an message encoded as a URL query variable named SAMLRequest.

<samlp:AuthnRequestxmlns: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="1">
<saml:Issuer>https://sp.example.com/SAML2</saml:Issuer>
<samlp:NameIDPolicyAllowCreate="true"Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient"/>
</samlp:AuthnRequest>

The query string is encoded using the DEFLATE encoding. The browser processes the redirect response and issues an HTTP GET request to the IdP's Single Sign-On Service with the SAMLRequest query parameter. The local state information (or a reference to it) is also included in the HTTP response encoded in a RelayState query string parameter.

https://idp.example.org/SAML2/SSO/Redirect?SAMLRequest=request&RelayState=token

3

The Single Sign-On Service determines whether the user has an existing logon security context at the identity provider that meets the default or requested (in the ) authentication policy requirements. If not, the IdP interacts with the browser to challenge the user to provide valid credentials.

4

The user provides valid credentials and a local logon security context is created for the user at the IdP.

5

The IdP Single Sign-On Service builds a SAML assertion representing the user's logon security context. Since a POST binding is going to be used, the assertion is digitally signed and then placed within a SAML message. The message is then placed within an HTML FORM as a hidden form control named SAMLResponse. If the IdP received a RelayState value from the SP, it must return it unmodified to the SP in a hidden form control named RelayState. The Single Sign-On Service sends the HTML form back to the browser in the HTTP response. For ease of use purposes, the HTML FORM typically will be accompanied by script code that will automatically post the form to the destination site.

<form method="post" action="https://sp.example.com/SAML2/SSO/POST" ...>
<input type="hidden" name="SAMLResponse" value="response" />
<input type="hidden" name="RelayState" value="token" />
...
<input type="submit" value="Submit" />
</form>

The value of the SAMLResponse parameter is the base64 encoding of the following samlp:Response element:

<samlp:Responsexmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"ID="identifier_2"InResponseTo="identifier_1"Version="2.0"IssueInstant="2004-12-05T09:22:05Z"Destination="https://sp.example.com/SAML2/SSO/POST">
<saml:Issuer>https://idp.example.org/SAML2</saml:Issuer>
<samlp:Status>
    <samlp:StatusCodeValue="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<saml:Assertionxmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"ID="identifier_3"Version="2.0"IssueInstant="2004-12-05T09:22:05Z">
<saml:Issuer>https://idp.example.org/SAML2</saml:Issuer><!-- a POSTed assertion MUST be signed -->
<ds:Signaturexmlns:ds="http://www.w3.org/2000/09/xmldsig#">...
</ds:Signature>
<saml:Subject>
    <saml:NameIDFormat="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">3f7b3dcf-1674-4ecd-92c8-1544f346baf8
    </saml:NameID>
    <saml:SubjectConfirmationMethod="urn:oasis:names:tc:SAML:2.0:cm:bearer">
    <saml:SubjectConfirmationDataInResponseTo="identifier_1"Recipient="https://sp.example.com/SAML2/SSO/POST"NotOnOrAfter="2004-12-05T09:27:05Z"/>
    </saml:SubjectConfirmation>
</saml:Subject>
<saml:ConditionsNotBefore="2004-12-05T09:17:05Z"NotOnOrAfter="2004-12-05T09:27:05Z">
<saml:AudienceRestriction>
    <saml:Audience>https://sp.example.com/SAML2</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatementAuthnInstant="2004-12-05T09:22:00Z"SessionIndex="identifier_3">
<saml:AuthnContext>
    <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
</saml:Assertion>
</samlp:Response>

6

The browser, due either to a user action or execution of an “auto-submit” script, issues an HTTP POST request to send the form to the SP's Assertion Consumer Service.

POST /SAML2/SSO/POST HTTP/1.1
Host: sp.example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: nnn
SAMLResponse=response&RelayState=token

where the values of the SAMLResponse and RelayState parameters are taken from the HTML form of Step 5.

The service provider's Assertion Consumer Service obtains the message from the HTML FORM for processing. The digital signature on the SAML assertion must first be validated and then the assertion contents are processed in order to create a local logon security context for the user at the SP. Once this completes, the SP retrieves the local state information indicated by the RelayState data to recall the originally-requested resource URL. It then sends an HTTP redirect response to the browser directing it to access the originally requested resource (not shown).

7

An access check is made to establish whether the user has the correct authorization to access the resource. If the access check passes, the resource is then returned to the browser.

Ref

http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html
https://www.cnblogs.com/shuidao/p/3463947.html

标签:based,Service,SP,Flow,SSO,user,HTTP,example
From: https://www.cnblogs.com/talentzemin/p/17688506.html

相关文章

  • 构筑下一代数据中心互联的“超级高速公路”,中科驭数正式发布KPU FLEXFLOW®-2100R RDM
    2023服贸会期间,中科驭数重磅推出最新自研的高性能网络“利器”——KPUFLEXFLOW®-2100RRDMA加速DPU卡。这款产品的发布标志着中科驭数在高性能计算和数据中心领域的不断创新,旨在面向高速网络、高性能存储搭建起算力集群内部通信的"超级高速公路”,助力高性能计算领域创新。站在数......
  • 工作流-Flowable
    1.工作流概述1.1概念工作流(Workflow),就是通过计算机对业务流程自动化执行管理。它主要解决的是“使在多个参与者之间按照某种预定义的规则自动进行传递文档、信息或任务的过程,从而实现某个预期的业务目标,或者促使此目标的实现”。工作流的作用是对业务流程进行自动化管理,......
  • AutoC平台搭建指南(基于NXP i.MX RT1170 MCUXPresso开发环境建设 @Like)
    AutoC平台搭建指南(基于NXPi.MXRT1170MCUXPresso开发环境建设@Like)(2022-11-17)目录1.功能需求 2.硬件平台 3.软件工具环境 4.建设基础 5.安装开发工具和环境 5.1.MCUXpressoIDE 5.2.i.MXRT1170SDK 5.3.GUI-Guider-1.4.1-GA 6.创建应用工程 6.1.导入SDK例程 6.1.1.......
  • AutoC平台搭建指南(基于NXP i.MX RT1170 MCUXPresso开发环境建设 @Like)
    AutoC平台搭建指南(基于NXPi.MXRT1170MCUXPresso开发环境建设@Like)(2022-11-17) 目录1.功能需求2.硬件平台3.软件工具环境4.建设基础5.安装开发工具和环境5.1.MCUXpressoIDE5.2.i.MXRT1170SDK5.3.GUI-Guider-1.4.1-GA6.创建应用工程6.1.导入SDK例程6......
  • Annotation processors must be explicitly declared now
    AndroidStudio升级到最新版3.0Canary8后,当使用到注解时,报了如下错误:Error:Executionfailedfortask':app:javaPreCompileDebug'.>Annotationprocessorsmustbeexplicitlydeclarednow.Thefollowingdependenciesonthecompileclasspatharefoundtocontain......
  • 机器学习算法原理实现——使用梯度下降求解Lasso回归和岭回归
    本文本质上是在线性回归的基础上进行扩展,加入了正则化而已!机器学习算法原理实现——使用梯度下降求解线性回归 正则化在机器学习中是一种防止过拟合的技术,它通过在损失函数中添加一个惩罚项来限制模型的复杂度。举一个实际的例子,假设你正在训练一个机器学习模型来预测房价。你......
  • All Pairs Maximum Flow题解
    前置知识:1.P3376【模板】网络最大流2.P4897【模板】最小割树(Gomory-HuTree)Ebola有一句很著名的话如果你乱搞过了我请你抽烟那么这道题肯定不能普通的dinic直接水过去,不然就不是紫题了,那么直接祭出最小割树,复杂度\(O(Tn^3m)\),但是因为dinic跑不满,所以是可以过的。......
  • GitHub workflows env All In One
    GitHubworkflowsenvAllInOne$GITHUB_ENVdocsGITHUB_ENVenvironmentfile#把变量和值`>>`追加到GITHUB_ENV环境变量文件中echo"{environment_variable_name}={value}">>"$GITHUB_ENV"steps:-name:Setthevalueid:step_......
  • SSO 单点登
    1.概述1.1.什么是SSO?单点登录(SingleSign-On,简称SSO)是目前比较流行的服务于企业业务整合的解决方案之一,SSO使得在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。我们目前的系统存在诸多子系统,而这些子系统是分别部署在不同的服务器中,那么使......
  • a different object with the same identifier value was already associated with th
    数据库更新记录报错:adifferentobjectwiththesameidentifiervaluewasalreadyassociatedwiththesession:[com.miracle.dm.sysmgr.user.model.OrgUserProInfo#4028800b269cc2f301269cc959960007];nestedexceptionisorg.hibernate.NonUniqueObjectException:adiffe......