rubycas-client 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +49 -22
- data/init.rb +1 -0
- data/install.rb +4 -0
- data/lib/cas_auth.rb +0 -17
- metadata +3 -2
data/README
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
= RubyCAS-Client
|
2
2
|
|
3
|
-
Author:: Ola Bini <ola.bini AT ki DOT se>, Matt Zukowski <matt AT roughest DOT net>
|
3
|
+
Author:: Ola Bini <ola.bini AT ki DOT se>, Matt Zukowski <matt AT roughest DOT net>, Matt Walker <mwalker AT tamu DOT edu>
|
4
4
|
Copyright:: (c) 2006 Karolinska Institutet, portions (c) 2006 Urbacon Ltd.
|
5
5
|
License:: GNU Lesser General Public License v2.1 (LGPL 2.1)
|
6
|
-
Website:: http://rubyforge.org/projects/rubycas-client
|
6
|
+
Website:: http://rubyforge.org/projects/rubycas-client and http://code.google.com/p/rubycas-client
|
7
7
|
|
8
8
|
=== RubyCAS-Client is a Ruby client library for Yale's Central Authentication Service (CAS) protocol.
|
9
9
|
|
@@ -21,10 +21,10 @@ This CAS client library is designed to work easily with Rails, but can of course
|
|
21
21
|
|
22
22
|
== Installing
|
23
23
|
|
24
|
-
You can always download the latest version of RubyCAS-Client from the project's rubyforge page at http://rubyforge.org/projects/rubycas-client
|
25
|
-
|
24
|
+
You can always download the latest version of RubyCAS-Client from the project's rubyforge page at http://rubyforge.org/projects/rubycas-client.
|
25
|
+
However probably the easiest way to install CAS support into your Rails app is via the plugins facility:
|
26
26
|
|
27
|
-
./script/plugin install http://rubycas-client.rubyforge.org/plugin/
|
27
|
+
./script/plugin install http://rubycas-client.rubyforge.org/plugin/rubycas-client
|
28
28
|
|
29
29
|
Alternatively, the library is also available as a gem, which can be installed by:
|
30
30
|
|
@@ -32,34 +32,32 @@ Alternatively, the library is also available as a gem, which can be installed by
|
|
32
32
|
|
33
33
|
The latest development version is availabe via subversion:
|
34
34
|
|
35
|
-
|
35
|
+
./script/plugin install -x http://rubycas-client.googlecode.com/svn/trunk/rubycas-client
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
./script/plugin install -x svn://rubyforge.org/var/svn/rubycas-client/trunk/ruby
|
40
|
-
|
41
|
-
Please contact the developers via the {rubyforge.org page}[svn checkout svn://rubyforge.org/var/svn/rubycas-client] if you have bug fixes
|
37
|
+
Please contact the developers via the {rubyforge.org page}[http://rubyforge.org/projects/rubycas-client] if you have bug fixes
|
42
38
|
or enhancements you would like to contribute back.
|
43
39
|
|
44
40
|
== Examples
|
45
41
|
|
46
42
|
==== Here is an example of how to use the library in your Rails application:
|
47
43
|
|
48
|
-
Somewhere in your
|
49
|
-
you'll need to
|
44
|
+
Somewhere in your <tt>config/environment.rb</tt> file add this (assuming that you have RubyCAS-Client installed as a plugin, otherwise
|
45
|
+
you'll need to <tt>require 'cas_auth'</tt> and <tt>require 'cas_proxy_callback_controller'</tt>):
|
50
46
|
|
51
47
|
CAS::Filter.cas_base_url = "https://login.example.com/cas"
|
52
48
|
|
53
|
-
Then, in your
|
49
|
+
Then, in your <tt>app/controllers/application.rb</tt> (or in whatever controller you want to add the CAS filter for):
|
54
50
|
|
55
51
|
before_filter CAS::Filter
|
56
52
|
|
57
|
-
That's it. You should now find that you are redirected to your CAS login page
|
58
|
-
in your protected controller. You can of course qualify the
|
59
|
-
filter. For example:
|
53
|
+
That's it. You should now find that you are redirected to your CAS login page whenever you try to access any action
|
54
|
+
in your protected controller. You can of course qualify the <tt>before_filter</tt> as you would with any other ActionController
|
55
|
+
filter. For example:
|
56
|
+
|
57
|
+
before_filter CAS::Filter, :except => [ :unprotected_action, :another_unprotected_action ]
|
60
58
|
|
61
|
-
<b>Once the user has been authenticated, their authenticated username is available under
|
62
|
-
(and also under
|
59
|
+
<b>Once the user has been authenticated, their authenticated username is available under <tt>request.username</tt></b>
|
60
|
+
(and also under <tt>session[:casfilteruser]</tt>). If you want to do something with this username (for example load a
|
63
61
|
user record from the database), you can append another filter method that checks for this value and does whatever you need
|
64
62
|
it to do.
|
65
63
|
|
@@ -94,18 +92,36 @@ when your application requests to act as a CAS proxy, the CAS server must contac
|
|
94
92
|
Confused? Don't worry, you don't really have to understand this to use it. To enable your Rails app to act as a CAS proxy,
|
95
93
|
all you need to do is this:
|
96
94
|
|
97
|
-
In your
|
95
|
+
In your <tt>config/environment.rb</tt>:
|
98
96
|
|
99
97
|
CAS::Filter.cas_base_url = "https://login.example.com/cas"
|
100
98
|
CAS::Filter.proxy_callback_url = "https://yourrailsapp.com/cas_proxy_callback/receive_pgt"
|
101
99
|
CAS::Filter.proxy_retrieval_url = "https://yourrailsapp.com/cas_proxy_callback/retrieve_pgt"
|
102
100
|
|
103
|
-
In
|
101
|
+
In <tt>config/routes.rb</tt> make sure that you have a route that will allow requests to /cas_proxy_callback/:action to be routed to the
|
104
102
|
CasProxyCallbackController. This should work as-is with the standard Rails routes setup, but if you have disabled the default
|
105
103
|
route, you should add the following:
|
106
104
|
|
107
105
|
map.cas_proxy_callback 'cas_proxy_callback/:action', :controller => 'cas_proxy_callback'
|
108
106
|
|
107
|
+
Now here's a big giant caveat: <b>your CAS callback application and your CAS proxy application must run on separate Rails servers</b>.
|
108
|
+
In other words, if you want a Rails app to act as a CAS ticket-granting proxy, the cas_proxy_callback controller
|
109
|
+
must run on a different server. This is because Rails does not properly support handling of concurrent requests. The CAS proxy mechanism
|
110
|
+
acts in such a way that if your proxy application and your callback controller were on the same server
|
111
|
+
you would end up with a deadlock (the CAS server would be waiting for its callback to be accepted by your Rails server,
|
112
|
+
but your Rails server wouldn't respond to the CAS server's callback until the CAS server responded back first).
|
113
|
+
|
114
|
+
The simplest workaround is this:
|
115
|
+
|
116
|
+
1. Create an empty rails app (i.e. something like <tt>rails cas_proxy_callback</tt>)
|
117
|
+
2. Make sure that you have the CAS plugin installed. If you installed it as a gem, you don't have to do anything since
|
118
|
+
it is already installed. If you want to install as a plugin, see the instructions in the "Installing" section above.
|
119
|
+
3. Make sure that the server is up and running, and configure your proxy_callback_url and proxy_retrieval_url to point
|
120
|
+
to the new server as described above (or rather, make Pound point to the new server, if that's how you're handling https).
|
121
|
+
|
122
|
+
That's it. The proxy_callback_controller doesn't require any additional configuration. It doesn't access the database
|
123
|
+
or anything of that sort.
|
124
|
+
|
109
125
|
Once your user logs in to CAS via your application, you can do the following to obtain a service ticket that can then be used
|
110
126
|
to authenticate another application:
|
111
127
|
|
@@ -113,7 +129,7 @@ to authenticate another application:
|
|
113
129
|
proxy_granting_ticket = session[:casfilterpgt]
|
114
130
|
ticket = CAS::Filter.request_proxy_ticket(service_uri, proxy_granting_ticket)
|
115
131
|
|
116
|
-
|
132
|
+
<tt>ticket</tt> should now contain a valid service ticket. You can use it to authenticate your other by sending it and the service URI
|
117
133
|
as query parameters to your target application:
|
118
134
|
|
119
135
|
http://some.other.application?service=#{ticket.target_service}&ticket=#{ticket.proxy_ticket}
|
@@ -145,6 +161,17 @@ to your Rails application. Also, note that <i>self-signed SSL certificates likel
|
|
145
161
|
a real certificate purchased from a trusted CA authority (there are ways around this, but good luck :)
|
146
162
|
|
147
163
|
|
164
|
+
== SSL Support
|
165
|
+
|
166
|
+
If you are getting an error on net/https -- something like this:
|
167
|
+
|
168
|
+
no such file to load -- net/https
|
169
|
+
|
170
|
+
Then make sure the library for open SSL is installed. For example, on an Debian/Ubuntu system issue the following:
|
171
|
+
|
172
|
+
sudo apt-get install libopenssl-ruby
|
173
|
+
|
174
|
+
|
148
175
|
== License
|
149
176
|
|
150
177
|
This program is free software; you can redistribute it and/or modify
|
data/init.rb
CHANGED
data/install.rb
CHANGED
data/lib/cas_auth.rb
CHANGED
@@ -1,23 +1,6 @@
|
|
1
|
-
# RubyCAS-Client is a client and Rails filter for the CAS protocol.
|
2
|
-
# Copyright (c) 2006 Karolinska Institutet
|
3
|
-
#
|
4
|
-
# This program is free software; you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation; either version 2 of the License
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License
|
14
|
-
# along with this program; if not, write to the Free Software Foundation,
|
15
|
-
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16
|
-
|
17
1
|
require 'uri'
|
18
2
|
require 'logger'
|
19
3
|
|
20
|
-
|
21
4
|
require File.dirname(File.expand_path(__FILE__))+'/cas'
|
22
5
|
|
23
6
|
module CAS
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rubycas-client
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.10.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.10.1
|
7
|
+
date: 2006-10-11 00:00:00 -04:00
|
8
8
|
summary: Client library for the CAS single-sign-on protocol.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -27,6 +27,7 @@ signing_key:
|
|
27
27
|
cert_chain:
|
28
28
|
authors:
|
29
29
|
- Matt Zukowski
|
30
|
+
- Ola Bini
|
30
31
|
- Matt Walker
|
31
32
|
files:
|
32
33
|
- install.rb
|