<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>config/cas.yml.example</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/CHANGELOG.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/History.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/LICENSE.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/Manifest.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/README.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/Rakefile</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/init.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/casclient.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/casclient/client.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/casclient/frameworks/rails/filter.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/casclient/responses.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/casclient/tickets.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/casclient/version.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/lib/rubycas-client.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rubycas-client/setup.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,7 @@ class ApplicationController &lt; ActionController::Base
   include ExceptionNotifiable
   include AuthenticatedSystem
   
+  before_filter CASClient::Frameworks::Rails::Filter if WebistranoConfig[:authentication_method] == :cas
   before_filter :login_from_cookie, :login_required
   around_filter :set_timezone
 </diff>
      <filename>app/controllers/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,8 +26,12 @@ class SessionsController &lt; ApplicationController
     self.current_user.forget_me if logged_in?
     cookies.delete :auth_token
     reset_session
-    flash[:notice] = &quot;You have been logged out.&quot;
-    redirect_back_or_default( home_path )
+    if WebistranoConfig[:authentication_method] != :cas
+      flash[:notice] = &quot;You have been logged out.&quot;
+      redirect_back_or_default( home_path )
+    else
+      redirect_to &quot;#{CASClient::Frameworks::Rails::Filter.config[:logout_url]}?serviceUrl=#{home_url}&quot;
+    end
   end
   
   def version</diff>
      <filename>app/controllers/sessions_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,9 @@
 class StylesheetsController &lt; ApplicationController
   
   skip_before_filter :login_required
+  if WebistranoConfig[:authentication_method] == :cas
+    skip_before_filter CASClient::Frameworks::Rails::Filter
+  end
   
   session :off
   </diff>
      <filename>app/controllers/stylesheets_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -99,7 +99,7 @@ class User &lt; ActiveRecord::Base
     end
     
     def password_required?
-      crypted_password.blank? || !password.blank?
+      WebistranoConfig[:authentication_method] != :cas &amp;&amp; (crypted_password.blank? || !password.blank?)
     end
 
     </diff>
      <filename>app/models/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,6 +9,7 @@
   &lt;%= text_field 'user', 'email', :style =&gt;'width:330px;' %&gt;
 &lt;/p&gt;
 
+&lt;% unless WebistranoConfig[:authentication_method] == :cas -%&gt;
 &lt;p&gt;
   &lt;b&gt;Password&lt;/b&gt;&lt;br /&gt;
   &lt;%= password_field 'user', 'password', :style =&gt;'width:330px;' %&gt;
@@ -18,6 +19,7 @@
   &lt;b&gt;Password confirmation&lt;/b&gt;&lt;br /&gt;
   &lt;%= password_field 'user', 'password_confirmation', :style =&gt;'width:330px;' %&gt;
 &lt;/p&gt;
+&lt;% end -%&gt;
 
 &lt;p&gt;
   &lt;b&gt;Timezone&lt;/b&gt;&lt;br /&gt;</diff>
      <filename>app/views/users/_form.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,7 @@ Rails::Initializer.run do |config|
   # Force all environments to use the same logger level
   # (by default production uses :info, the others :debug)
   # config.log_level = :debug
+  
 
   # Your secret key for verifying cookie session data integrity.
   # If you change this key, all old sessions will become invalid!
@@ -76,6 +77,11 @@ end
 
 # Include your application configuration below
 
+if WebistranoConfig[:authentication_method] == :cas
+  cas_options = YAML::load_file(RAILS_ROOT+'/config/cas.yml')
+  CASClient::Frameworks::Rails::Filter.configure(cas_options[RAILS_ENV])
+end
+
 WEBISTRANO_VERSION = '1.4'
 
 ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(:log =&gt; '%Y-%m-%d %H:%M')</diff>
      <filename>config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,9 @@ WebistranoConfig = {
 
   # secret password for session HMAC
   :session_secret =&gt; 'please choose a long random string, min. 30 characters',
+
+  # Uncomment to use CAS authentication
+  # :authentication_method =&gt; :cas,
   
   # SMTP settings for outgoing email
   :smtp_delivery_method =&gt; :sendmail,
@@ -26,5 +29,5 @@ WebistranoConfig = {
   # Sender and recipient for Webistrano exceptions
   :exception_recipients =&gt; &quot;team@example.com&quot;,
   :exception_sender_address =&gt; &quot;webistrano@example.com&quot;
-  
+
 }</diff>
      <filename>config/webistrano_config.rb.sample</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@ module AuthenticatedSystem
     # Accesses the current user from the session.  Set it to :false if login fails
     # so that future calls do not hit the database.
     def current_user
-      @current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || :false)
+      @current_user ||= (login_from_cas || login_from_session || login_from_basic_auth || login_from_cookie || :false)
     end
     
     # Store the given user in the session.
@@ -95,6 +95,11 @@ module AuthenticatedSystem
       base.send :helper_method, :current_user, :logged_in?
     end
 
+    # Called from #current_user.  First attempt to login by the user id from cas.
+    def login_from_cas
+      self.current_user = User.find_by_login(session[:cas_user]) if session[:cas_user]
+    end
+
     # Called from #current_user.  First attempt to login by the user id stored in the session.
     def login_from_session
       self.current_user = User.find_by_id(session[:user]) if session[:user]</diff>
      <filename>lib/authenticated_system.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>76b00ded89f7c92eed1883b412fa4c801a3b9df4</id>
    </parent>
  </parents>
  <author>
    <name>Tim Shadel</name>
    <email>github@timshadel.com</email>
  </author>
  <url>http://github.com/timshadel/webistrano/commit/24a304afeabf5dcc9139e5bbb7396bdbf56b711c</url>
  <id>24a304afeabf5dcc9139e5bbb7396bdbf56b711c</id>
  <committed-date>2008-10-09T10:06:27-07:00</committed-date>
  <authored-date>2008-09-23T13:25:03-07:00</authored-date>
  <message>Add CAS authentication as an option.

To use:
* Login with an existing admin user (like the default admin/admin)
* Create a new user with a login that matches their CAS login
* Give that user a dummy password (it won't be checked)
* Stop Webistrano
* Uncomment the CAS setting (see config/webistrano_config.rb.sample)
* Start Webistrano
* When accessing Webistrano, you should be sent to the CAS page, or you
  should be automatically logged in if you've signed in already.

Signed-off-by: Tim Shadel &lt;github@timshadel.com&gt;</message>
  <tree>9284ddf2d4f083f2128d89543e050e7d2da5b0c9</tree>
  <committer>
    <name>Tim Shadel</name>
    <email>github@timshadel.com</email>
  </committer>
</commit>
