summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-02-26 13:09:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-02-26 13:09:25 +0000
commita78d5659593d9fcce02a24a95c0ca0d111706465 (patch)
tree6b729c9b4f6d1413af78c5fe59a2a29bbc954b44 /app/models
parente1ad561cf652713bbdebe2d60fc4c680fb367ec1 (diff)
downloadredmine-a78d5659593d9fcce02a24a95c0ca0d111706465.tar.gz
redmine-a78d5659593d9fcce02a24a95c0ca0d111706465.zip
Adds support for SCM/LDAP passwords encryption in the database (#7411).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4950 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/auth_source.rb10
-rw-r--r--app/models/auth_source_ldap.rb4
-rw-r--r--app/models/repository.rb11
3 files changed, 23 insertions, 2 deletions
diff --git a/app/models/auth_source.rb b/app/models/auth_source.rb
index 84f17b1bc..e9922ca56 100644
--- a/app/models/auth_source.rb
+++ b/app/models/auth_source.rb
@@ -16,6 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class AuthSource < ActiveRecord::Base
+ include Redmine::Ciphering
+
has_many :users
validates_presence_of :name
@@ -31,6 +33,14 @@ class AuthSource < ActiveRecord::Base
def auth_method_name
"Abstract"
end
+
+ def account_password
+ read_ciphered_attribute(:account_password)
+ end
+
+ def account_password=(arg)
+ write_ciphered_attribute(:account_password, arg)
+ end
def allow_password_changes?
self.class.allow_password_changes?
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
index d2a7e7041..6b23c670c 100644
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -20,8 +20,8 @@ require 'iconv'
class AuthSourceLdap < AuthSource
validates_presence_of :host, :port, :attr_login
- validates_length_of :name, :host, :account_password, :maximum => 60, :allow_nil => true
- validates_length_of :account, :base_dn, :maximum => 255, :allow_nil => true
+ validates_length_of :name, :host, :maximum => 60, :allow_nil => true
+ validates_length_of :account, :account_password, :base_dn, :maximum => 255, :allow_nil => true
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
validates_numericality_of :port, :only_integer => true
diff --git a/app/models/repository.rb b/app/models/repository.rb
index c9d7d0dbe..075ecbe34 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -16,6 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Repository < ActiveRecord::Base
+ include Redmine::Ciphering
+
belongs_to :project
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
has_many :changes, :through => :changesets
@@ -24,6 +26,7 @@ class Repository < ActiveRecord::Base
# has_many :changesets, :dependent => :destroy is too slow for big repositories
before_destroy :clear_changesets
+ validates_length_of :password, :maximum => 255, :allow_nil => true
# Checks if the SCM is enabled when creating a repository
validate_on_create { |r| r.errors.add(:type, :invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
@@ -36,6 +39,14 @@ class Repository < ActiveRecord::Base
def root_url=(arg)
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
end
+
+ def password
+ read_ciphered_attribute(:password)
+ end
+
+ def password=(arg)
+ write_ciphered_attribute(:password, arg)
+ end
def scm_adapter
self.class.scm_adapter_class