JASIG CAS协议介绍 (3)--/validate和/serviceValidate

3.4. /validate [CAS 1.0]

/validate检查ST的有效性,/validateCAS1.0协议的一部分,因此不处理代理认证。当一个代理凭证通过/validate时,CAS必须作出反应。

3.4.1. parameters

下面的HTTP请求的参数可以指定为/验证。它们是区分大小写的,必须全部交由/验证。

 •service[需要] –服务的标识符,是需要带着ticket访问的服务。

 •ticket[需要] -/login发出的服务凭证(ST)。服务车票的描述见3.1节。

 •renew[可选] -如果这个参数设定,凭证验证将只在ST是来自用户的主证书时才会通过验证,如果ticket是来自SSO session,则验证失败。

即,只用通过主登录页面过来的附带着ST的请求,才能被验证。

3.4.2. response

/validate will return one of the following two responses:

On ticket validation success:

yes<LF>

username<LF>

On ticket validation failure:

no<LF>

<LF>

3.4.3. URL examples of /validate

Simple validation attempt:

https://server/cas/validate?service=http%3A%2F%2Fwww.service.com&ticket=ST-1856339-aA5Yuvrxzpv8Tau1cYQ7

Ensure service ticket was issued by presentation of primary credentials:

https://server/cas/validate?service=http%3A%2F%2Fwww.service.com&ticket=ST-1856339-aA5Yuvrxzpv8Tau1cYQ7&renew=true

3.5. /serviceValidate [CAS 2.0]

/serviceValidate检查ST的有效性,并且返回一个XML片段。 当被请求时,/serviceValidate还必须创造和传出PGTproxy-granting ticket,代理准许凭证)。如果/serviceValidate收到只是一个PTproxy ticket,代理凭证),它不可以返回一个成功的验证。CAS推荐:如果/ serviceValidate收到PT,应该在返回的XML响应的错误信息里说明失败的原因,原因是由于PT传递到了/ serviceValidate。也即:/ serviceValidate不能负责校验PT

3.5.1. parameters

下面的HTTP请求的参数是/ serviceValidate可以指定的。它们是区分大小写的,必须全部交由/ serviceValidate处理。

 •service[需要] -服务的标识符,是需要带着ticket访问的服务。第2.2.1节。

 •ticket[需要] - /login发出的服务凭证(ST)。ST将在3.1节详解。

 • pgtUrl [可选] -代理回调的URL。将在2.5.4节讨论。

 •renew[可选] -如果这个参数设定,凭证验证将只在ST是来自用户的主认证时才会通过验证,如果ticket是来自SSO session,则验证失败。

3.5.2. response

/ serviceValidate将返回一个格式化的CASserviceResponse XML,详细描述参加附录A

On ticket validation success:

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>

    <cas:authenticationSuccess>

        <cas:user>username</cas:user>

            <cas:proxyGrantingTicket>PGTIOU-84678-8a9d...

        </cas:proxyGrantingTicket>

    </cas:authenticationSuccess>

</cas:serviceResponse>

On ticket validation failure:

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>

    <cas:authenticationFailure code="INVALID_TICKET">

        Ticket ST-1856339-aA5Yuvrxzpv8Tau1cYQ7 not recognized

    </cas:authenticationFailure>

</cas:serviceResponse>

3.5.3. error codes

下面的值可能被用来作为验证失败时“code”属性的值。以下是最低限度的错误代码,所有CAS服务器必须实现的,当然还包括其他一些实现。

  INVALID_REQUEST -请求参数不全。上面讲到至少必须有“service”和“ticket”两个参数。

  INVALID_TICKET -提供的ticket无效,或者你的“renew”属性设置为true,而不是从主认证(/login)过来的。返回的XML中的消息体中的<cas:authenticationFailure>块应说明具体细节。

  INVALID_SERVICE -提供ticket是有效的,但是和服务规定的ticket并不匹配。CAS必须使这张ticket失效,并禁止今后再验证该ticket

  INTERNAL_ERROR ticket验证时发生内部错误。

对于所有的错误代码,CAS推荐为<cas:authenticationFailure>提供更详细的描述信息。

3.5.4. proxy callback

如果一个服务想代理一个客户端到终端服务(Back-end service)的认证,他必须获得一个PGTproxy-granting ticket,代理授予凭证)。要获取这个凭证是受代理回调URL控制的。这个URL将唯一的和安全的识别终端服务,并且代理客户端的认证请求。终端服务然后基于自身的识别回调URL来决定是否接受这个证书。

The proxy callback mechanism works as follows:

代理回调机制的工作流程如下:

1.     The service that is requesting a proxy-granting ticket specifies upon initial service ticket or proxy ticket validation the HTTP request parameter "pgtUrl" to /serviceValidate (or /proxyValidate). This is a callback URL of the service to which CAS will connect to verify the service's identity. This URL MUST be HTTPS, and CAS MUST verify both that the SSL certificate is valid and that its name matches that of the service.

If the certificate fails validation, no proxy-granting ticket will be issued, and the CAS service response as described in Section 2.5.2 MUST NOT contain a <proxyGrantingTicket> block. At this point, the issuance of a proxy-granting ticket is halted, but service ticket validation will continue, returning success or failure as appropriate. If certificate validation is successful, issuance of a proxy-granting ticket proceeds as in step 2.

1.想使用代理认证的服务需要一个PGT,这个PGT来自初始的ST或者PT,并且是通过设置HTTP请求参数“pgturl”在/serviceValidate(或/ proxyValidate)上确认才得到的。这就是一个服务的回调URLCAS服务器将链接到它并且验证服务的身份信息。这个URL必须是HTTPS的,并且CAS必须确认SSL证书是有效的,并且它的名字与它请求的服务相匹配。

如果证书验证失败,将不发放PGT,并且就像第2.5.2节中描述的,必须使CAS服务返回的XML<proxyGrantingTicket>不包含PGT。在这一点上,PGT停止发布,但ST验证仍将继续,还要根据现状返回成功或失败。如果证书验证成功,发行PGT的过程见如下第2步。

2.     CAS uses an HTTP GET request to pass the HTTP request parameters "pgtId" and "pgtIou" to the pgtUrl. These entities are discussed in Sections 3.3 and 3.4, respectively.

2.CAS使用HTTP GET请求传递HTTP请求的参数“ pgtId ”和“ pgtIou ”到pgtUrl。实际上是在具有代理功能的客户端配置的一个servlet。这些实体将在第3.33.4中讨论。

3.     If the HTTP GET returns an HTTP status code of 200 (OK), CAS MUST respond to the /serviceValidate (or /proxyValidate) request with a service response (Section 2.5.2) containing the proxy-granting ticket IOU (Section 3.4) within the <cas:proxyGrantingTicket> block. If the HTTP GET returns any other status code, excepting HTTP 3xx redirects, CAS MUST respond to the /serviceValidate (or /proxyValidate) request with a service response that MUST NOT contain a <cas:proxyGrantingTicket> block. CAS MAY follow any HTTP redirects issued by the pgtUrl. However, the identifying callback URL provided upon validation in the <proxy> block MUST be the same URL that was initially passed to /serviceValidate (or /proxyValidate) as the "pgtUrl" parameter.

3.如果HTTPGET返回HTTP状态码200 (正常),CAS必须以服务响应的方式响应/serviceValidate (或/proxyValidate )的请求(第2.5.2节),并且在响应返回的XML<cas:proxyGrantingTicket>节点上包含PGTIOUProxy-granting ticket IOU)(第3.4节)。如果HTTP GET返回的是其他状态码,除的HTTP 3xx重定向外,CAS必须以服务响应的方式响应/serviceValidate (或/ proxyValidate )的请求,并且在响应返回的XML中不能包含<cas:proxyGrantingTicket>块。

CAS可跟踪pgturl传出的任何HTTP重定向。但不管怎样,在<proxy>节点中提供验证的回调URL,必须与最初通过/ serviceValidate (或/ proxyValidate )的“pgturl”参数相同。

4.     The service, having received a proxy-granting ticket IOU in the CAS response, and both a proxy-granting ticket and a proxy-granting ticket IOU from the proxy callback, will use the proxy-granting ticket IOU to correlate the proxy-granting ticket with the validation response. The service will then use the proxy-granting ticket for the acquisition of proxy tickets as described in Section 2.7.

4.代理服务,收到CAS服务器返回的PGTIOU,并且通过代理回调还能获得一个PGT(事实上返回的PGTPGTIOU都被存储下来),然后通过使用PGTIOU与与PGT进行匹配。这样就能找到需要的PGT,利用这个PGT就可以得到PTproxy-ticket)。参见第2.7节。

3.5.5. URL examples of /serviceValidate

Simple validation attempt:

https://server/cas/serviceValidate?service=http%3A%2F%2Fwww.service.com&ticket=ST-1856339-aA5Yuvrxzpv8Tau1cYQ7

Ensure service ticket was issued by presentation of primary credentials:

https://server/cas/serviceValidate?service=http%3A%2F%2Fwww.service.com&ticket= ST-1856339-aA5Yuvrxzpv8Tau1cYQ7&renew=true

Pass in a callback URL for proxying:

https://server/cas/serviceValidate?service=http%3A%2F%2Fwww.service.com&ticket=ST-1856339-aA5Yuvrxzpv8Tau1cYQ7&pgtUrl=https://my-server/myProxyCallback

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值