rubycas-client 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -1,114 +1 @@
1
- = RubyCAS-Client Changelog
2
-
3
- == Version 2.0.1 :: 2008-02-27
4
-
5
- * The Rails filter no longer by default redirects to the CAS server on
6
- every request. This restores the behaviour of RubyCAS-Client 1.x.
7
- In other words, if a session[:cas_user] value exists, the filter
8
- will assume that the user is authenticated without going through the
9
- CAS server. This behaviour can be disabled (so that a CAS re-check is
10
- done on every request) by setting the 'authenticate_on_every_request'
11
- option to true. See the "Re-authenticating on every request" section
12
- in the README.txt for details.
13
-
14
- == Version 2.0.0 :: 2008-02-14
15
-
16
- * COMPLETE RE-WRITE OF THE ENTIRE CLIENT FROM THE GROUND UP. Oh yes.
17
- * Core client has been abstracted out of the Rails adapter. It should now
18
- be possible to use the client in other frameworks (e.g. Camping).
19
- * Configuration syntax has completely changed. In other words, your old
20
- rubycas-client-1.x configuration will no longer work. See the README
21
- for details.
22
- * Added support for reading extra attributes from the CAS response (i.e. in
23
- addition to just the username). However currently this is somewhat useless
24
- since RubyCAS-Server does not yet provide a method for adding extra
25
- attributes to the responses it generates.
26
-
27
- == Version 1.1.0 :: 2007-12-21
28
-
29
- * Fixed serious bug having to do with logouts. You can now end the
30
- CAS session on the client-side (i.e. force the client to re-authenticate)
31
- by setting session[:casfilteruser] = nil.
32
- * Added new GatewayFilter. This is identical to the normal Filter but
33
- has the gateway option set to true by default. This should make
34
- using the gateway option easier.
35
- * The CAS::Filter methods are now properly documented.
36
- * Simplified guess_service produces better URLs when redirecting to the CAS
37
- server for authentication and the service URL is not explicitly specified.
38
- [delagoya]
39
- * The correct method for overriding the service URL for the client is now
40
- properly documented. You should use service_url=, as server_name= no longer
41
- works and instead generates a warning message.
42
- * logout_url() now takes an additional 'service' parameter. If specified, this
43
- URL will be passed on to the CAS server as part of the logout URL.
44
-
45
- == Version 1.0.0 :: 2007-07-26
46
-
47
- * RubyCAS-Client has matured to the point where it is probably safe to
48
- take it out of beta and release version 1.0.
49
- * Non-SSL CAS URLs will now work. This may be useful for demo purposes,
50
- but certainly shouldn't be used in production. The client automatically
51
- disables SSL if the CAS URL starts with http (rather than https). [rubywmq]
52
-
53
- == Version 0.12.0
54
-
55
- * Prior to redirecting to the CAS login page, the client now stores the
56
- current service URI in a session variable. This value is used to
57
- validate the service ticket after the user comes back from the CAS
58
- server's login page. This should address issues where redirection
59
- from the CAS server resulted in a slightly different URI from the original
60
- one used prior to login redirection (for example due to variations in the
61
- way routing rules are applied by the server).
62
- * The client now handles malformed CAS server responses more gracefully.
63
- This makes debugging a malfunctioning CAS server somewhat easier.
64
- * When receiving a proxy-granting ticket, the cas_proxy_callback_controller
65
- can now take a parameter called 'pgt' (which is what ought to be used
66
- according to the published CAS spec) or 'pgtId' (which is what the JA-SIG
67
- CAS server uses).
68
- * Logging has been somewhat quieted down. Many messages that were previously
69
- logged as INFO are now logged as DEBUG.
70
-
71
- == Version 0.11.0
72
-
73
- * Added this changelog to advise users of major changes to the library.
74
-
75
- * Large chunks of the library have been re-written. Beware of the possibility
76
- of new bugs (although the re-write was meant to fix a whole slew of existing
77
- bugs, so you're almost certainly better off upgrading).
78
-
79
- * service and targetService parameters in requests are now properly URI-encoded,
80
- so the filter should behave properly when your service has query parameters.
81
- Thanks sakazuki for pointing out the problem.
82
-
83
- * You can now force the CAS client to re-authenticate itself with the CAS server
84
- (i.e. override the authentication stored in the session) by providing a new
85
- service ticket in the URI. In other words, the client will authenticate with
86
- CAS if: a) you have a 'ticket' parameter in the URI, and there is currently no
87
- authentication info in the session, or b) you have a 'ticket' parameter in the
88
- URI and this ticket is different than the ticket that was used to authenticat
89
- the existing session. This is especially useful when you are using CAS proxying,
90
- since it allows you to force re-authentication in proxied applications (for
91
- example, when the user has logged out and a new user has logged in in the parent
92
- proxy-granting application).
93
-
94
- * If your service URI has a 'ticket' parameter, it will now be automatically
95
- removed when passing the service as a parameter in any CAS request. This is
96
- done because at least some CAS servers will happily accept a service URI with
97
- a 'ticket' parameter, which will result in a URI with multiple 'ticket'
98
- parameters once you are redirected back to CAS (and that in turn can result
99
- in an endless redirection loop).
100
-
101
- * Logging has been greatly improved, which should make debugging your CAS
102
- installation much easier. Look for the logs under log/cas_client_RAILS_ENV.log
103
-
104
- * When you install RubyCAS-Client as a Rails plugin, it will now by default
105
- use a custom logger. You can change this by explicitly setting your own
106
- logger in your environment.rb, or by modifying the plugin's init.rb.
107
-
108
- * CasProxyCallbackController no longer checks to make sure that the incoming
109
- request is secure. The check is impossible since the secure header is not
110
- passed on by at least some reverse proxies (like Pound), and if you are using
111
- the callback controller then you are almost certainly also using a reverse
112
- proxy.
113
-
114
- * Cleaned up and updated documentation, fixed some example code.
1
+ See History.txt
data/History.txt CHANGED
@@ -0,0 +1,162 @@
1
+ = RubyCAS-Client Changelog
2
+
3
+ == Version 2.1.0 :: 2009-08-18
4
+
5
+ * New functionality:
6
+ * Added an adapter for the Merb framework. Thanks to Andrew O'Brien and
7
+ Antono Vasiljev.
8
+ * Implemented single-sign-out functionality. The client will now intercept
9
+ single-sign-out requests and deal with them appropriately if the
10
+ :enable_single_sign_out config option is set to true. This is currently
11
+ disabled by default. (Currently this is only implemented for the Rails
12
+ adapter)
13
+ * Added logout method to Rails adapter to simplify the logout process. The
14
+ logout method resets the local Rails session and redirects to the CAS
15
+ logout page.
16
+ * Added login_url method to the Rails filter. This will return the login
17
+ URL for the current controller; useful when you want to show a "Login"
18
+ link in a gatewayed page for an unauthenticated user.
19
+ * Added cas_server_is_up? method to the client, as requested in issue #5.
20
+ * Extra user attributes are now automatically unserialized if the incoming data
21
+ is in YAML format.
22
+
23
+ * Changes to existing functionality:
24
+ * The 'service' parameter in the logout method has been renamed to
25
+ 'destination' to better match the behaviour of other CAS clients. So for
26
+ example, when you call logout_url("http://foo.example"), the method will
27
+ now return "https://cas.example?destination=https%3A%2F%2Ffoo.example"
28
+ instead of the old "https://cas.example?service=https%3A%2F%2Ffoo.example".
29
+ RubyCAS-Server has been modified to deal with this as of version 0.6.0.
30
+ * We now accept HTTP responses from the CAS server with status code 422 since
31
+ RubyCAS-Server 0.7.0+ generates these in response to requests that are
32
+ processable but contain invalid CAS data (for example an invalid service
33
+ ticket).
34
+ * Some behind-the-scenes changes to the way previous authentication info is
35
+ reused by the Rails filter in subsequent requests (see the note below
36
+ in the 2.0.1 release). From the user's and integrator's point of view
37
+ there shouldn't be any obvious difference from 2.0.1.
38
+ * Redirection loop interception: The client now logs a warning message when it
39
+ believes that it is stuck in a redirection loop with the CAS server. If more
40
+ than three of these redirects occur within one second, the client will
41
+ redirect back to the login page with renew=1, forcing the user to try
42
+ authenticating again.
43
+ * Somewhat better handling and logging of errors resulting from CAS server
44
+ connection/response problems.
45
+
46
+ * Bug Fixes:
47
+ * Fixed bug where the the service/destination parameter in the logout url
48
+ would sometimes retain the 'ticket' value. The ticket is now automatically
49
+ stripped from the logout url.
50
+ * The client will no longer attempt to retrieve a PGT for an IOU that had
51
+ already been previously retrieved. [yipdw1]
52
+
53
+ * Misc:
54
+ * Added complete CAS client integration examples for Rails and Merb
55
+ applications under /examples.
56
+
57
+ == Version 2.0.1 :: 2008-02-27
58
+
59
+ * The Rails filter no longer by default redirects to the CAS server on
60
+ every request. This restores the behaviour of RubyCAS-Client 1.x.
61
+ In other words, if a session[:cas_user] value exists, the filter
62
+ will assume that the user is authenticated without going through the
63
+ CAS server. This behaviour can be disabled (so that a CAS re-check is
64
+ done on every request) by setting the 'authenticate_on_every_request'
65
+ option to true. See the "Re-authenticating on every request" section
66
+ in the README.txt for details.
67
+
68
+ == Version 2.0.0 :: 2008-02-14
69
+
70
+ * COMPLETE RE-WRITE OF THE ENTIRE CLIENT FROM THE GROUND UP. Oh yes.
71
+ * Core client has been abstracted out of the Rails adapter. It should now
72
+ be possible to use the client in other frameworks (e.g. Camping).
73
+ * Configuration syntax has completely changed. In other words, your old
74
+ rubycas-client-1.x configuration will no longer work. See the README
75
+ for details.
76
+ * Added support for reading extra attributes from the CAS response (i.e. in
77
+ addition to just the username). However currently this is somewhat useless
78
+ since RubyCAS-Server does not yet provide a method for adding extra
79
+ attributes to the responses it generates.
80
+
81
+ ------------------------------------------------------------------------------
82
+
83
+ == Version 1.1.0 :: 2007-12-21
84
+
85
+ * Fixed serious bug having to do with logouts. You can now end the
86
+ CAS session on the client-side (i.e. force the client to re-authenticate)
87
+ by setting session[:casfilteruser] = nil.
88
+ * Added new GatewayFilter. This is identical to the normal Filter but
89
+ has the gateway option set to true by default. This should make
90
+ using the gateway option easier.
91
+ * The CAS::Filter methods are now properly documented.
92
+ * Simplified guess_service produces better URLs when redirecting to the CAS
93
+ server for authentication and the service URL is not explicitly specified.
94
+ [delagoya]
95
+ * The correct method for overriding the service URL for the client is now
96
+ properly documented. You should use service_url=, as server_name= no longer
97
+ works and instead generates a warning message.
98
+ * logout_url() now takes an additional 'service' parameter. If specified, this
99
+ URL will be passed on to the CAS server as part of the logout URL.
100
+
101
+ == Version 1.0.0 :: 2007-07-26
102
+
103
+ * RubyCAS-Client has matured to the point where it is probably safe to
104
+ take it out of beta and release version 1.0.
105
+ * Non-SSL CAS URLs will now work. This may be useful for demo purposes,
106
+ but certainly shouldn't be used in production. The client automatically
107
+ disables SSL if the CAS URL starts with http (rather than https). [rubywmq]
108
+
109
+ == Version 0.12.0
110
+
111
+ * Prior to redirecting to the CAS login page, the client now stores the
112
+ current service URI in a session variable. This value is used to
113
+ validate the service ticket after the user comes back from the CAS
114
+ server's login page. This should address issues where redirection
115
+ from the CAS server resulted in a slightly different URI from the original
116
+ one used prior to login redirection (for example due to variations in the
117
+ way routing rules are applied by the server).
118
+ * The client now handles malformed CAS server responses more gracefully.
119
+ This makes debugging a malfunctioning CAS server somewhat easier.
120
+ * When receiving a proxy-granting ticket, the cas_proxy_callback_controller
121
+ can now take a parameter called 'pgt' (which is what ought to be used
122
+ according to the published CAS spec) or 'pgtId' (which is what the JA-SIG
123
+ CAS server uses).
124
+ * Logging has been somewhat quieted down. Many messages that were previously
125
+ logged as INFO are now logged as DEBUG.
126
+
127
+ == Version 0.11.0
128
+
129
+ * Added this changelog to advise users of major changes to the library.
130
+ * Large chunks of the library have been re-written. Beware of the possibility
131
+ of new bugs (although the re-write was meant to fix a whole slew of existing
132
+ bugs, so you're almost certainly better off upgrading).
133
+ * service and targetService parameters in requests are now properly URI-encoded,
134
+ so the filter should behave properly when your service has query parameters.
135
+ Thanks sakazuki for pointing out the problem.
136
+ * You can now force the CAS client to re-authenticate itself with the CAS server
137
+ (i.e. override the authentication stored in the session) by providing a new
138
+ service ticket in the URI. In other words, the client will authenticate with
139
+ CAS if: a) you have a 'ticket' parameter in the URI, and there is currently no
140
+ authentication info in the session, or b) you have a 'ticket' parameter in the
141
+ URI and this ticket is different than the ticket that was used to authenticat
142
+ the existing session. This is especially useful when you are using CAS proxying,
143
+ since it allows you to force re-authentication in proxied applications (for
144
+ example, when the user has logged out and a new user has logged in in the parent
145
+ proxy-granting application).
146
+ * If your service URI has a 'ticket' parameter, it will now be automatically
147
+ removed when passing the service as a parameter in any CAS request. This is
148
+ done because at least some CAS servers will happily accept a service URI with
149
+ a 'ticket' parameter, which will result in a URI with multiple 'ticket'
150
+ parameters once you are redirected back to CAS (and that in turn can result
151
+ in an endless redirection loop).
152
+ * Logging has been greatly improved, which should make debugging your CAS
153
+ installation much easier. Look for the logs under log/cas_client_RAILS_ENV.log
154
+ * When you install RubyCAS-Client as a Rails plugin, it will now by default
155
+ use a custom logger. You can change this by explicitly setting your own
156
+ logger in your environment.rb, or by modifying the plugin's init.rb.
157
+ * CasProxyCallbackController no longer checks to make sure that the incoming
158
+ request is secure. The check is impossible since the secure header is not
159
+ passed on by at least some reverse proxies (like Pound), and if you are using
160
+ the callback controller then you are almost certainly also using a reverse
161
+ proxy.
162
+ * Cleaned up and updated documentation, fixed some example code.
data/Manifest.txt CHANGED
@@ -2,11 +2,18 @@ CHANGELOG.txt
2
2
  History.txt
3
3
  LICENSE.txt
4
4
  Manifest.txt
5
- README.txt
5
+ README.rdoc
6
6
  Rakefile
7
+ examples/merb/README.textile
8
+ examples/merb/Rakefile
9
+ examples/merb/merb.thor
10
+ examples/merb/merb_auth_cas.rb
11
+ examples/merb/spec/spec_helper.rb
7
12
  init.rb
8
13
  lib/casclient.rb
9
14
  lib/casclient/client.rb
15
+ lib/casclient/frameworks/merb/filter.rb
16
+ lib/casclient/frameworks/merb/strategy.rb
10
17
  lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb
11
18
  lib/casclient/frameworks/rails/filter.rb
12
19
  lib/casclient/responses.rb
@@ -3,7 +3,10 @@
3
3
  Author:: Matt Zukowski <matt AT roughest DOT net>; inspired by code by Ola Bini <ola.bini AT ki DOT se> and Matt Walker <mwalker AT tamu DOT edu>
4
4
  Copyright:: (c) 2008 Urbacon Ltd.
5
5
  License:: GNU Lesser General Public License v2.1 (LGPL 2.1)
6
- Website:: http://code.google.com/p/rubycas-client and http://rubyforge.org/projects/rubycas-client
6
+ Websites:: http://code.google.com/p/rubycas-client
7
+ http://github.com/gunark/rubycas-client
8
+ http://rubyforge.org/projects/rubycas-client
9
+
7
10
 
8
11
 
9
12
  === RubyCAS-Client is a Ruby client library for Yale's Central Authentication Service (CAS) protocol.
@@ -16,6 +19,10 @@ For general information about the open CAS protocol, please have a look at http:
16
19
  If your organization does not already have a CAS server, you may be interested in RubyCAS-Client's sister project,
17
20
  RubyCAS-Server[http://code.google.com/p/rubycas-server/].
18
21
 
22
+ The RubyCAS-Client package includes adapters for Rails and Merb, although the client library itself can be
23
+ adapted for other frameworks (for example an implementation for Camping is available via the Picnic[http://github.com/zuk/picnic/tree/master]
24
+ library).
25
+
19
26
 
20
27
  == Getting help and reporting problems
21
28
 
@@ -23,13 +30,15 @@ If you need help, try posting to the RubyCAS discussion group at http://groups.g
23
30
 
24
31
  To report problems, please use the Google Code issue tracker at http://code.google.com/p/rubycas-client/issues/list.
25
32
 
33
+ API documentation (i.e. the RDocs) are available at http://rubycas-client.rubyforge.org
34
+
26
35
 
27
36
  == Installation
28
37
 
29
38
  You can download the latest version of RubyCAS-Client from the project's rubyforge page at
30
39
  http://rubyforge.org/projects/rubycas-client.
31
40
 
32
- However, it is easier to install the CAS client into a Ruby on Rails app as a plugin:
41
+ However, if you're using Rails, it's easier to install the CAS client as a plugin:
33
42
 
34
43
  cd <your rails app>
35
44
  ./script/plugin install http://rubycas-client.googlecode.com/svn/trunk/rubycas-client
@@ -43,17 +52,27 @@ you always have the latest bleeding-edge version of RubyCAS-Client:
43
52
 
44
53
  ./script/plugin install -x http://rubycas-client.googlecode.com/svn/trunk/rubycas-client
45
54
 
55
+ With Rails 2.1 or newer, it is also possible to install the plugin directly from the bleeding-edge git repository:
56
+
57
+ ./script/plugin install git://github.com/gunark/rubycas-client.git
46
58
 
47
59
  == Usage Examples
48
60
 
49
- Although RubyCAS-Client can be used with other web Frameworks (for example Camping), the following examples
50
- are aimed at {Ruby on Rails}[http://rubyonrails.org].
61
+ If you'd rather jump right in, have a look at the example Rails and Merb applications pre-configured for CAS
62
+ authentication:
63
+
64
+ http://github.com/gunark/rubycas-client/tree/master/examples
65
+
66
+
67
+ Otherwise, continue reading for a step-by-step guide for integrating RubyCAS-Client with Rails:
68
+
51
69
 
52
70
  ==== Using RubyCAS-Client in Rails controllers
53
71
 
54
72
  <i>Note that from this point on we are assuming that you have a working CAS server up and running!</i>
55
73
 
56
- After installing RubyCAS-Client as a plugin (see above), add the following to your app's <tt>config/environment.rb</tt>:
74
+ After installing RubyCAS-Client as a plugin (see above), add the following to your app's <tt>config/environment.rb</tt>
75
+ (make sure that you put it at the bottom of the file, *after* the Rails Initializer):
57
76
 
58
77
  CASClient::Frameworks::Rails::Filter.configure(
59
78
  :cas_base_url => "https://cas.example.foo/"
@@ -76,6 +95,11 @@ filter. For example:
76
95
  If you want to do something with this username (for example load a user record from the database), you can append another
77
96
  filter method that checks for this value and does whatever you need it to do.
78
97
 
98
+ <b>Note:</b> If Rails complains about missing constants, try adding this before the CASClient configuration:
99
+
100
+ require 'casclient'
101
+ require 'casclient/frameworks/rails/filter'
102
+
79
103
 
80
104
  ==== A more complicated example
81
105
 
@@ -91,19 +115,19 @@ Here is a more complicated configuration showing most of the configuration optio
91
115
  :login_url => "https://cas.example.foo/login",
92
116
  :logout_url => "https://cas.example.foo/logout",
93
117
  :validate_url => "https://cas.example.foo/proxyValidate",
94
- :session_username_key => :cas_user,
95
- :session_extra_attributes_key => :cas_extra_attributes
118
+ :username_session_key => :cas_user,
119
+ :extra_attributes_session_key => :cas_extra_attributes,
96
120
  :logger => cas_logger,
97
- :authenticate_on_every_request => true
121
+ :enable_single_sign_out => true
98
122
  )
99
123
 
100
- Note that it is normally not necessary to specify <tt>:login_url</tt>, <tt>:logout_url</tt>, and <tt>:validate_url</tt>.
124
+ Note that normally it is not necessary to specify <tt>:login_url</tt>, <tt>:logout_url</tt>, and <tt>:validate_url</tt>.
101
125
  These values are automatically set to standard CAS defaults based on the given <tt>:cas_base_url</tt>.
102
126
 
103
- The <tt>:session_username_key</tt> value determines the key under which you can find the CAS username in the Rails session hash.
127
+ The <tt>:username_session_key</tt> value determines the key under which you can find the CAS username in the Rails session hash.
104
128
 
105
129
  Any additional info that the CAS server might have supplied about the user during authentication will be found under the
106
- <tt>:session_extra_attributes_key</tt> value in the Rails session hash (i.e. given the above configuration, you would find this
130
+ <tt>:extra_attributes_session_key</tt> value in the Rails session hash (i.e. given the above configuration, you would find this
107
131
  info under <tt>session[:cas_extra_attributes]</tt>).
108
132
 
109
133
  An arbitrary Logger instance can be given as the :logger parameter. In the example above we log all CAS activity to a
@@ -119,29 +143,49 @@ the disadvantage is that the filter no longer checks to make sure that the user'
119
143
  In other words it is possible for the user's authentication session to be closed on the CAS server without the
120
144
  client application knowing about it.
121
145
 
122
- In the future RubyCAS-Client will support the new "Single Sign-Out" functionality in CAS 3.1, allowing the server to
123
- notify the client application that the CAS session is closed, but for now it is up to you to handle this by, for example,
124
- by wiping the local session[:cas_user] value periodically to force a CAS re-check.
146
+ To address this, RubyCAS-Client now supports the new "Single Sign-Out" functionality in CAS 3.1, allowing the server to
147
+ notify the client application that the CAS session is closed. The client will automatically intercept Single Sign-Out
148
+ requsts from the CAS server, but in order for this to work you must configure your Rails application as follows:
149
+
150
+ 1. The Rails session store must be set to ActiveRecord: <tt>config.action_controller.session_store = :active_record_store</tt>
151
+ 2. The server must be able to read and write to RAILS_ROOT/tmp/sessions. If you are in a clustered environment,
152
+ the contents of this directory must be shared between all server instances.
153
+ 3. Cross-site request forgery protection must be disabled. In your <tt>application.rb</tt>: <tt>self.allow_forgery_protection = false</tt>.
154
+ (Or rather you may want to disable forgery protection only for actions that are behind the CAS filter.)
155
+ 4. Finally, you must add <tt>:enable_single_sign_out => true</tt> to your CAS client config (a similar option must be
156
+ enabled on the CAS server, if you're using RubyCAS-Server).
157
+
158
+ The best way to debug single-sign out functionality is to configure your CAS client with logging (see above) and then watch the
159
+ log to ensure that single-sign out requests from the server are being processed correctly.
160
+
125
161
 
126
- Alternatively, it is possible to disable this authentication persistence behaviour by setting the <tt>:authenticate_on_every_request</tt>
127
- configuration option to true as in the example above.
162
+ Alternatively, it is possible to disable authentication persistence in the client by setting the <tt>:authenticate_on_every_request</tt>
163
+ configuration option to true as, in the example in the previous section. However, this is not recommended as it will almost
164
+ certainly have a deleterious impact on performance and can interfere with certain HTTP transactions (AJAX requests, for example).
128
165
 
129
166
 
130
167
  ==== Defining a 'logout' action
131
168
 
132
- Your Rails application's controller(s) will probably have some sort of logout function. In it you will likely reset the
133
- user's session for your application, and then redirect to the CAS server's logout URL. Here's an example of how to do this:
169
+ Your Rails application's controller(s) will probably have some sort of logout function. Here you can do any necessary local
170
+ cleanup, and then call <tt>CASClient::Frameworks::Rails::Filter.logout(controller)</tt>. For example:
134
171
 
135
- class ApplicationController < ActionController::Base
172
+ class ApplicationController < ActionController::Base
173
+
174
+ # ...
136
175
 
137
- # ...
138
-
139
- def logout
140
- reset_session
141
- redirect_to CAS::Filter.logout_url(self, request.referer)
176
+ def logout
177
+ # optionally do some local cleanup here
178
+ # ...
179
+
180
+ CASClient::Frameworks::Rails::Filter.logout(self)
181
+ end
142
182
  end
143
- end
144
183
 
184
+ By default, the logout method will clear the local Rails session, do some local CAS cleanup, and redirect to the CAS
185
+ logout page. Additionally, the <tt>request.referer</tt> value from the <tt>controller</tt> instance is passed to the
186
+ CAS server as a 'destination' parameter. This allows RubyCAS server to provide a follow-up login page allowing
187
+ the user to log back in to the service they just logged out from using a different username and password. Other
188
+ CAS server implemenations may use this 'destination' parameter in different ways.
145
189
 
146
190
  ==== Gatewayed (i.e. optional) authentication
147
191
 
@@ -161,6 +205,9 @@ CAS authentication for all actions in a controller except the index action:
161
205
  # ...
162
206
  end
163
207
 
208
+ To provide a login URL for unauthenticated users:
209
+
210
+ <%= link_to("Login", CASClient::Frameworks::Rails::Filter.login_url(controller)) %>
164
211
 
165
212
  ==== How to act as a CAS proxy
166
213
 
@@ -221,12 +268,12 @@ to authenticate another application:
221
268
 
222
269
  service_uri = "http://some-other-application.example.foo"
223
270
  proxy_granting_ticket = session[:cas_pgt]
224
- ticket = CASClient::Frameworks::Rails::Filter.client.request_proxy_ticket(service_uri, proxy_granting_ticket).ticket
271
+ proxy_ticket = CASClient::Frameworks::Rails::Filter.client.request_proxy_ticket(service_uri, proxy_granting_ticket)
225
272
 
226
- <tt>ticket</tt> should now contain a valid service ticket. You can use it to authenticate other services by sending it and
273
+ <tt>proxy_ticket</tt> should now contain a valid proxy ticket. You can use it to authenticate other services by sending it together with
227
274
  the service URI as parameters to your target application:
228
275
 
229
- http://some-other-application.example.foo?service=#{CGI.encode(ticket.target_service)}&ticket=#{ticket.proxy_ticket}
276
+ http://some-other-application.example.foo?service=#{CGI::escape(proxy_ticket.service)}&ticket=#{proxy_ticket.ticket}
230
277
 
231
278
  This is of course assuming that http://some-other-application.example.foo is also protected by the CAS filter.
232
279
  Note that you should always URI-encode your service parameter inside URIs!
@@ -272,4 +319,4 @@ GNU General Public License for more details.
272
319
 
273
320
  You should have received a copy of the GNU Lesser General Public License
274
321
  along with this program (see the file called LICENSE); if not, write to the
275
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
322
+ Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA