cas3.0协议规范

原文:
https://apereo.github.io/cas/4.2.x/protocol/CAS-Protocol-Specification.html

1.介绍

这是CAS 1.0, 2.0 and 3.0协议的官方规范
Central Authentication Service (CAS)是web的单点登录/单点登出(single-sign-on / single-sign-off)协议。用户仅需向central CAS Server提供一次凭证(如userid和password)就可以访问不同的应用。

1.1定义

  • “Client”指end user and/or 浏览器
  • “CAS Client”指通过CAS协议与CAS server交互的应用
  • “Server”指Central Authentication Service server
  • “Service”指client试图访问的应用
  • “Back-end service”指service代表client试图访问的应用,又称作“target service.”
  • “SSO”指Single Sign on
  • “SLO” 指Single Logout

2.CAS URIs

URI 描述
/login credential requestor / acceptor
/logout destroy CAS session (logout)
/validate service ticket validation
/serviceValidate service ticket validation [CAS 2.0]
/proxyValidate service/proxy ticket validation [CAS 2.0]
/proxy proxy ticket service [CAS 2.0]
/p3/serviceValidate service ticket validation [CAS 3.0]
/p3/proxyValidate service/proxy ticket validation [CAS 3.0]

2.1/login作为credential requestor

如果client与CAS已经建立了单点登录会话,浏览器会向CAS传递一个安全cookie,cookie包含一个确定ticket-granting ticket的字符串。这个cookie被称作ticket-granting cookie。

2.1.1参数

作为credential requestor时,下面的HTTP请求参数可被传递给/login,大小写敏感

  • service [OPTIONAL]-client 试图访问的应用标识。大多数情况下,就是应用的URL。作为请求参数,URL必须是URL-encoded。如果一个service还没被specified并且单点登录会话没被创建,CAS应当要求用户提供凭证以创建单点登录会话。如果一个service还没被specified但是单点登录会话已经存在,CAS应当显示一条信息通知client已经登录。
    强烈建议使用service management tool过滤所有的service urls,只有authorized 和known client applications可以使用cas server,否则会增加被攻击、带来不安全的风险。还有就是建议使用https协议

  • renew [OPTIONAL] -如果存在这个参数,会绕过单点登录。不管是否存在单点登录会话,CAS都会要求client提供凭证。不能同时使用renew和gateway参数。

  • gateway [OPTIONAL] -如果存在这个参数,CAS不要求client提供凭证。如果client有之前存在的单点登录会话,或者可以通过非交互的方式(例如:trust authentication)创建一个单点登录会话,CAS MAY将client重定向到service 参数指定的url,并附加有效的 service ticket,否则不带service ticket重定向
  • method [OPTIONAL, CAS 3.0]

2.1.2/login例子

**Simple login example:**
https://cas.example.org/cas/login?service=http%3A%2F%2Fwww.example.org%2Fservice
**Don’t prompt for username/password:**
https://cas.example.org/cas/login?service=http%3A%2F%2Fwww.example.org%2Fservice&gateway=true
**Always prompt for username/password:**
https://cas.example.org/cas/login?service=http%3A%2F%2Fwww.example.org%2Fservice&renew=true
**Use POST responses instead of redirects:**
https://cas.example.org/cas/login?method=POST&service=http%3A%2F%2Fwww.example.org%2Fservice

2.1.3username/password认证的响应

/login作为credential requestor时,响应会由需要的凭证的类型而不同。大部分情况下,CAS会返回一个需要 username and password的登录窗口。页面必须包含含有以下参数的表单:“username”, “password”, and “lt”。也可以包含“warn”参数。如果service参数传递给/login,service也必须是这个表单的参数,值为传给/login的参数值。通过HTTP POST提交这个form到/login,此时/login会作为credential acceptor。

2.1.4trust authentication的响应

trust authentication适应对请求的任意方面的考虑作为认证的基础。考虑到本地政策和所实施的特定认证机制的后勤工作,适当的用户体验信任认证将高度依赖于部署者。(谷歌翻译)

2.1.5response for single sign-on authentication

如果client已经与CAS建立了single sign-on session,client应当已经将HTTP session cookie传递给/login,参见2.2.4节。否则,如果设置了renew参数,参见2.1.3 or 2.1.4节

2.2/login作为credential acceptor

2.2.1所有认证类型的通用参数

作为credential acceptor时,以下HTTP请求参数可被传递给/login,大小写敏感

  • service [OPTIONAL]
  • warn [OPTIONAL] -设置了这个参数,单点登录一定不是透明的。client被认证到另一个service前必须被提示
  • method [OPTIONAL]

2.2.2username/password认证的参数

除了上面的几个可选参数外,当使用username/password认证时,以下几个参数也必须传给/login
- username [REQUIRED]
- password [REQUIRED]
- lt [OPTIONAL] - a login ticket
- rememberMe [OPTIONAL, CAS 3.0] -被设置后,一个长期的Ticket Granting Ticket会被创建
Note: When Long-Term Ticket Granting Tickets (Remember Me) are supported by the CAS Server, security considerations MUST be taken into account. This for example includes shared computer usage. On CAS client systems it might be necessary to handle Remember-Me logins different. See Section 4.1 for details.

2.2.3. parameters for trust authentication

2.2.4.response

作为credential acceptor时,必须提供下面中响应的一个

  • successful login:将client重定向到service参数指定的url。client向service发送一个GET request。request必须包含一个有效的service ticket,以HTTP请求参数传递。如果没指定service, CAS必须显示一个消息通知client已经成功初始化一个单点登录会话
  • failed login:return to /login as a credential requestor。建议在这种情况下CAS server给用户展示一个描述失败原因的信息(如错误密码,账户锁定等),合适的话,尝试让用户重新登录。

2.3./logout

/logout销毁client的单点登录会话。ticket-granting cookie被销毁,后面发送到/login的请求无法获得获得service tickets直到用户提供凭证

2.3.1.参数

  • service [OPTIONAL, CAS 3.0]

2.3.2. response

[CAS 1.0, CAS 2.0] /logout必须展示一个页面指示用户已经登出

2.3.3.Single Logout

SLO指用户不止从CAS server登出,还包含所有已经访问过的CAS client应用。如果 CAS Server支持SLO,一旦Ticket Granting Ticket被用户显示的置为过期,在CAS 会话中, CAS Server必须发送一个包含logout XML document的HTTP POST请求 到所有提供给CAS的service URLs。不支持SLO POST的 CAS Clients必须忽略这些请求。TGT idle 超时时也可能由CAS Server触发SLO请求。

2.3.3.1.Server behaviour

CAS Server应当忽略在发送给CAS Client应用的service urls slo请求时产生的错误,以确保CAS Server正常运行

2.3.3.2.Client behaviour

由CAS client决定如何处理logout POST请求数据。建议登出用户。如果client支持SLO请求,应当返回HTTP成功状态码

2.4. /validate [CAS 1.0]

/validate校验service ticket的有效性。/validate是CAS 1.0协议的一部分,所以不能处理 proxy authentication。

2.4.1. 参数

  • service [REQUIRED]
  • ticket [REQUIRED] -由/login发放的service ticket
  • renew [OPTIONAL]

2.4.2.响应

ticket校验成功返回:yes
校验失败返回:no

2.4.3.URL examples of /validate

**Simple validation attempt:**
https://cas.example.org/cas/validate?service=http%3A%2F%2Fwww.example.org%2Fservice&ticket=ST-1856339-aA5Yuvrxzpv8Tau1cYQ7

**Ensure service ticket was issued by presentation of primary credentials:**
https://cas.example.org/cas/validate?service=http%3A%2F%2Fwww.example.org%2Fservice&ticket=ST-1856339-aA5Yuvrxzpv8Tau1cYQ7&renew=true

猜你喜欢

转载自blog.csdn.net/lovelovelovelovelo/article/details/79386006