Proxy CAS Walkthrough

8 篇文章 0 订阅
4 篇文章 0 订阅

Proxy CAS Walkthrough

A manual walkthrough of CAS proxy tickets.
This walkthrough was provided by David Spencer on the CAS Mailman list.

Introduction

When I was trying to understand the mechanisms involved in writing proxying applications using CAS, I found it very helpful to manually walkthrough the aquisition of a proxy ticket. The CAS server played itself in this exercise and I played all the other roles - user, proxying application and proxied application - simply by constructing URLs and feeding them into a web browser.

The only part of the exercise that can't be done with just a web browser and careful URL construction is the part where CAS makes it's own callback to the proxying application. For this, I chose a proxy callback url on a machine for which I had access to the log files and scanned through the HTTP requests to find the information I wanted.

Step One: login

To start with, log in to CAS with some invented service:

https://foo.bar.com/is/cas/login?service=http://localhost/bling


On successful login, CAS will redirect you to the service with a ticket appended (it doesn't matter that the service is made up as the ticket you're after is part of the url and will appear in the location bar even if your browser can't find the resource):

http://localhost/bling?ticket=ST-956-Lyg0BdLkgdrBO9W17bXS


Step Two

(a): verify the ticket and be done

So, playing the role of the first application (not a proxying application at this stage - lets just see if we can get our application authenticated without proxying for now), you need to take the ticket and turn it into a username:

https://foo.bar.com/is/cas/serviceValidate?ticket=ST-956-Lyg0BdLkgdrBO9W17bXS&service=http://localhost/bling


which will produce a result like:

<cas:serviceResponse xmlns:cas



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





<cas:authenticationSuccess>




<cas:user>

endjs</cas:user>




</cas:authenticationSuccess>




</cas:serviceResponse>

This is the end of the road for normal applications that don't need to proxy other applications.

Step Two (b): verify the ticket and enable further proxying

If instead you do want to be able to proxy other applications you need to also supply a pgtUrl to your validation request so that CAS can callback with the Proxy Granting Ticket. This is where life gets complicated, especially if you forget that service tickets are one-time-only tickets and that once you've used them with serviceValidate, you have to go back to CAS and get a new one (so if you've done Step One and Step Two (a) you'll need to do Step One again before you can do Step Two (b)).

The choice of pgtUrl here is fairly arbitrary except that it needs to be an https url and it needs to be on a server on which you can access the log files.

https://foo.bar.com/is/cas/serviceValidate?ticket=ST-956-Lyg0BdLkgdrBO9W17bXS

&service=http://localhost/bling&pgtUrl=https://foo.bar.com/pgtCallback


 


results in:

<cas:serviceResponse xmlns:cas



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





<cas:authenticationSuccess>




<cas:user>

endjs</cas:user>




<cas:proxyGrantingTicket>

PGTIOU-85-8PFx8qipjkWYDbuBbNJ1roVu4yeb9WJIRdngg7fzl523Eti2td</cas:proxyGrantingTicket>




</cas:authenticationSuccess>




</cas:serviceResponse>

Step Three: dig out the PGT

Now our first application knows who the user is and has a Proxy Granting Ticket IOU. To find the real PGT we look in the apache access log for foo.bar.com and hunt out the request made by CAS to deliver the PGT:

foo.bar.com - - [10/Dec/2003:09:28:15 +0000] "GET


/pgtCallback?pgtIou=PGTIOU-85-8PFx8qipjkWYDbuBbNJ1roVu4yeb9WJIRdngg7fzl523Eti2td


&pgtId=PGT-330-CSdUc5fCBz3g8KDDiSgO5osXfLMj9sRDAI0xDLg7jPn8gZaDqS HTTP/1.1" 200 13079


(Editor's note: linebreaks introduced for page formatting.)

Step Four: get a proxy ticket

With the PGT in our grasp we can make a call on CAS to give us a proxy ticket for some other service we wish to proxy:

https://foo.bar.com/is/cas/proxy?targetService=http://localhost/bongo&pgt=PGT-330-CSdUc5fCBz3g8KDDiSgO5osXfLMj9sRDAI0xDLg7jPn8gZaDqS


resulting in:

<cas:serviceResponse>






<cas:proxySuccess>




<cas:proxyTicket>

PT-957-ZuucXqTZ1YcJw81T3dxf</cas:proxyTicket>




</cas:proxySuccess>




</cas:serviceResponse>

Step Five: verify the proxy ticket

Now we take on our final role for the exercise - the proxied application. The proxying application has invoked our service url and has passed in the proxy ticket it's got. We take that ticket and validate it to find out both who the user is and which applications are in the proxy chain:

https://foo.bar.com/is/cas/proxyValidate?service=http://localhost/bongo&ticket=PT-957-ZuucXqTZ1YcJw81T3dxf


resulting in:

<cas:serviceResponse xmlns:cas



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





<cas:authenticationSuccess>




<cas:user>

endjs</cas:user>




<cas:proxies>




<cas:proxy>

https://foo.bar.com/pgtCallback</cas:proxy>




</cas:proxies>




</cas:authenticationSuccess>




</cas:serviceResponse>

Obviously, this walkthrough doesn't help with acquiring and plugging in good proxying code for your application but it does help to see what the proxying code needs to be doing and makes it easier to write your own.

Originally provided by: David Spencer on the CAS mailing list.


Useful links:

Cas installation:

http://www.ja-sig.org/wiki/display/CASUM/Demo

Java Client:

http://www.ja-sig.org/wiki/display/CASC/Using+the+basic+Java+CAS+Client+objects

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的公寓报修管理系统,源码+数据库+毕业论文+视频演示 现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本公寓报修管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此公寓报修管理系统利用当下成熟完善的Spring Boot框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。公寓报修管理系统有管理员,住户,维修人员。管理员可以管理住户信息和维修人员信息,可以审核维修人员的请假信息,住户可以申请维修,可以对维修结果评价,维修人员负责住户提交的维修信息,也可以请假。公寓报修管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。 关键词:公寓报修管理系统;Spring Boot框架;MySQL;自动化;VUE
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值