CAS reverse authentication mechanism

xiaoxiao2021-03-06  14

A Manual Walkthrough of Cas Proxy Tickets.This Walkthrough Was Provided by David Spencer on The Cas Mailman List.

IntroductionWhen 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 Theim Into a web browser.

The only part of the exercise that can not 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 information i wanted.

Step One: Loginto 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 does not 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 / bright? 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:

Endjs

This is the end of the road for normal application.

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 The WION 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 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:

Endjs

pgtiou-85-8pfx8qipjkwydbbnj1rovu4yeb9wjirdngg7fzl523eti2td

Step Three:. Dig out the PGTNow 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-8pfx8qipjkwydbubbnj1rovu4yeb9wjirdng7fzl523eti2td

& pgtid = pgt-330-csduc5fcbz3g8kddisgo5osxflmj9srdai0xdlg7jpn8gzadqs http / 1.1 "200 13079

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

Step Four: Get a proxy Ticketwith The PGT IUR 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:

PT-957-ZUUCXQTZ1YCJW81T3DXF

Step Five:.. Verify the proxy ticketNow 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 application area in the proxy chain:

https://foo.bar.com/is/cas/proxyvalidate?service=http://localhost/bongo&ticket=pt-957-zuucxqtz1ycjw81t3dxf

Resulting in:

Endjs

https://foo.bar.com/pgtcallback

Obviously, this walkthrough does not 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.

转载请注明原文地址:https://www.9cbs.com/read-49649.html

New Post(0)