SSO

SSO英文全称Single Sign On,单点登录。SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。它包括可以将这次主要的登录映射到其他应用中用于同一个用户的登录的机制。它是目前比较流行的企业业务整合的解决方案之一。

  SSO技术实现机制

  当用户第一次访问应用系统1的时候,因为还没有登录,会被引导到认证系统中进行登录;根据用户提供的登录信息,认证系统进行身份效验,如果通过效验,应该返回给用户一个认证的凭据--ticket;用户再访问别的应用的时候就会将这个ticket带上,作为自己认证的凭据,应用系统接受到请求之后会把ticket送到认证系统进行效验,检查ticket的合法性。如果通过效验,用户就可以在不用再次登录的情况下访问应用系统2和应用系统3了。

  要实现SSO,需要以下主要的功能:

  1、所有应用系统共享一个身份认证系统。

  统一的认证系统是SSO的前提之一。认证系统的主要功能是将用户的登录信息和用户信息库相比较,对用户进行登录认证;认证成功后,认证系统应该生成统一的认证标志(ticket),返还给用户。另外,认证系统还应该对ticket进行效验,判断其有效性。

  2、所有应用系统能够识别和提取ticket信息

  要实现SSO的功能,让用户只登录一次,就必须让应用系统能够识别已经登录过的用户。应用系统应该能对ticket进行识别和提取,通过与认证系统的通讯,能自动判断当前用户是否登录过,从而完成单点登录的功能。

  另外:

  1、单一的用户信息数据库并不是必须的,有许多系统不能将所有的用户信息都集中存储,应该允许用户信息放置在不同的存储中,如下图所示。事实上,只要统一认证系统,统一ticket的产生和效验,无论用户信息存储在什么地方,都能实现单点登录。

  2、统一的认证系统并不是说只有单个的认证服务器

  认证服务器之间要通过标准的通讯协议,互相交换认证信息,就能完成更高级别的单点登录。如:当用户在访问应用系统1时,由第一个认证服务器进行认证后,得到由此服务器产生的ticket。当他访问应用系统2的时候,认证服务器2能够识别此ticket是由第一个服务器产生的,通过认证服务器之间标准的通讯协议(例如SAML)来交换认证信息,仍然能够完成SSO的功能。

  WEB-SSO的实现

  用户在访问页面1的时候进行了登录,但是客户端的每个请求都是单独的连接,当客户再次访问页面2的时候,如何才能告诉Web服务器,客户刚才已经登录过了呢?浏览器和服务器之间有约定:通过使用cookie技术来维护应用的状态。Cookie是可以被Web服务器设置的字符串,并且可以保存在浏览器中。当浏览器访问了页面1时,web服务器设置了一个cookie,并将这个cookie和页面1一起返回给浏览器,浏览器接到cookie之后,就会保存起来,在它访问页面2的时候会把这个cookie也带上,Web服务器接到请求时也能读出cookie的值,根据cookie值的内容就可以判断和恢复一些用户的信息状态。Web-SSO完全可以利用Cookie结束来完成用户登录信息的保存,将浏览器中的Cookie和上文中的Ticket结合起来,完成SSO的功能。

  为了完成一个简单的SSO的功能,需要两个部分的合作:

  1、统一的身份认证服务。

  2、修改Web应用,使得每个应用都通过这个统一的认证服务来进行身份效验。

### Single Sign-On Overview Single Sign-On (SSO) is a session and user authentication service where one set of login credentials can be used to access multiple applications. This reduces password fatigue from using different passwords for each application, minimizes administrative overhead by simplifying password management, and increases security since users need only remember a single complex password rather than many simpler ones. In SSO systems, when a user logs into one system or website, that identity information propagates through all connected services without requiring additional logins. The process leverages standards like Security Assertion Markup Language (SAML), OpenID Connect, OAuth, among others[^1]. For instance, the claim `http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname` represents how specific attributes about the authenticated individual are shared between trusted parties within an SSO environment[^2]. ### Implementation Considerations Implementing SSO involves several critical components: - **Identity Provider (IdP):** Authenticates users and issues tokens. - **Service Providers (SPs):** Applications consuming these tokens issued by IdPs. - **Federation Protocols:** Standards such as SAML, WS-Federation, etc., facilitate secure communication between IdP and SPs. The architecture must support seamless integration with existing enterprise directories while ensuring robust security measures against unauthorized access attempts. Additionally, implementing multi-factor authentication enhances overall protection beyond just username/password combinations. ### Best Practices To maximize effectiveness and maintain high levels of security in deploying SSO solutions: - Ensure compatibility across diverse platforms including mobile devices. - Regularly update software versions along with patch installations promptly after release dates. - Conduct thorough risk assessments before integrating new third-party apps under the same umbrella. - Educate end-users on phishing threats targeting their primary account details which could compromise entire ecosystems once breached. ```python import requests from xml.etree import ElementTree def validate_saml_response(saml_response): """ Validates a received SAML response from Identity Provider Args: saml_response(str): Base64 encoded SAML Response Returns: bool: True if validation succeeds; False otherwise """ try: root = ElementTree.fromstring(requests.utils.unquote_plus(saml_response)) status_code = root.find('.//{urn:oasis:names:tc:SAML:2.0:protocol}StatusCode').attrib['Value'] return 'Success' == status_code except Exception as e: print(f"Validation failed due to {e}") return False ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值