Skip to content

Commit

Permalink
account: disallow password change
Browse files Browse the repository at this point in the history
  • Loading branch information
nackd committed Dec 29, 2010
1 parent 70a2b0d commit 477f29f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions init.rb
Expand Up @@ -7,6 +7,7 @@
require 'redmine' require 'redmine'
require 'cas/account_controller_patch' require 'cas/account_controller_patch'
require 'cas/application_controller_patch' require 'cas/application_controller_patch'
require 'cas/user_patch'


Redmine::Plugin.register :redmine_cas do Redmine::Plugin.register :redmine_cas do
name 'CAS Web Authentication' name 'CAS Web Authentication'
Expand Down
2 changes: 1 addition & 1 deletion lib/cas/account_controller_patch.rb
@@ -1,7 +1,6 @@
require 'casclient' require 'casclient'
require 'casclient/frameworks/rails/filter' require 'casclient/frameworks/rails/filter'
require 'dispatcher' require 'dispatcher'
require_dependency 'account_controller'


# Patches Redmine's AccountController dinamically. Manages login and logout # Patches Redmine's AccountController dinamically. Manages login and logout
# through CAS. # through CAS.
Expand Down Expand Up @@ -52,5 +51,6 @@ def register_with_cas
end end


Dispatcher.to_prepare do Dispatcher.to_prepare do
require_dependency 'account_controller'
AccountController.send(:include, CAS::AccountControllerPatch) AccountController.send(:include, CAS::AccountControllerPatch)
end end
2 changes: 1 addition & 1 deletion lib/cas/application_controller_patch.rb
@@ -1,7 +1,6 @@
require 'casclient' require 'casclient'
require 'casclient/frameworks/rails/filter' require 'casclient/frameworks/rails/filter'
require 'dispatcher' require 'dispatcher'
require_dependency 'application_controller'


# Patches Redmine's ApplicationController dinamically. Prepends a CAS gatewaying # Patches Redmine's ApplicationController dinamically. Prepends a CAS gatewaying
# filter. # filter.
Expand Down Expand Up @@ -50,5 +49,6 @@ def set_user_id
end end


Dispatcher.to_prepare do Dispatcher.to_prepare do
require_dependency 'application_controller'
ApplicationController.send(:include, CAS::ApplicationControllerPatch) ApplicationController.send(:include, CAS::ApplicationControllerPatch)
end end
28 changes: 28 additions & 0 deletions lib/cas/user_patch.rb
@@ -0,0 +1,28 @@
require 'dispatcher'

# Patches Redmine's User dinamically. Disallows password change.
module CAS
module UserPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)

base.class_eval do
unloadable # Mark as unloadable so it is reloaded in development

alias_method_chain :change_password_allowed?, :cas
end
end

module InstanceMethods
def change_password_allowed_with_cas?
CAS::CONFIG['enabled'] ? false : change_password_allowed_without_cas
end
end
end
end

Dispatcher.to_prepare do
require_dependency 'principal'
require_dependency 'user'
User.send(:include, CAS::UserPatch)
end

0 comments on commit 477f29f

Please sign in to comment.