Class: AuthSource

Inherits:
ApplicationRecord show all
Includes:
Redmine::Ciphering, Redmine::SafeAttributes, Redmine::SubclassFactory
Defined in:
app/models/auth_source.rb

Direct Known Subclasses

AuthSourceLdap

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Redmine::Ciphering

cipher_key, decrypt_text, encrypt_text, included, logger

Methods included from Redmine::SubclassFactory

included

Methods included from Redmine::SafeAttributes

#delete_unsafe_attributes, included, #safe_attribute?, #safe_attribute_names, #safe_attributes=

Methods inherited from ApplicationRecord

human_attribute_name

Class Method Details

.allow_password_changes?Boolean

Does this auth source backend allow password changes?

Returns:

  • (Boolean)


98
99
100
# File 'app/models/auth_source.rb', line 98

def self.allow_password_changes?
  false
end

.authenticate(login, password) ⇒ Object

Try to authenticate a user not yet registered against available sources



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'app/models/auth_source.rb', line 103

def self.authenticate(, password)
  AuthSource.where(:onthefly_register => true).each do |source|
    begin
      logger.debug "Authenticating '#{}' against '#{source.name}'" if logger && logger.debug?
      attrs = source.authenticate(, password)
    rescue => e
      logger.error "Error during authentication: #{e.message}"
      attrs = nil
    end
    return attrs if attrs
  end
  return nil
end

.search(q) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'app/models/auth_source.rb', line 79

def self.search(q)
  results = []
  AuthSource.all.each do |source|
    begin
      if source.searchable?
        results += source.search(q)
      end
    rescue AuthSourceException => e
      logger.error "Error while searching users in #{source.name}: #{e.message}"
    end
  end
  results
end

Instance Method Details

#account_passwordObject



63
64
65
# File 'app/models/auth_source.rb', line 63

def 
  read_ciphered_attribute(:account_password)
end

#account_password=(arg) ⇒ Object



67
68
69
# File 'app/models/auth_source.rb', line 67

def (arg)
  write_ciphered_attribute(:account_password, arg)
end

#allow_password_changes?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'app/models/auth_source.rb', line 93

def allow_password_changes?
  self.class.allow_password_changes?
end

#auth_method_nameObject



59
60
61
# File 'app/models/auth_source.rb', line 59

def auth_method_name
  "Abstract"
end

#authenticate(login, password) ⇒ Object



53
54
# File 'app/models/auth_source.rb', line 53

def authenticate(, password)
end

#searchable?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'app/models/auth_source.rb', line 71

def searchable?
  false
end

#test_connectionObject



56
57
# File 'app/models/auth_source.rb', line 56

def test_connection
end

#visible?(user = User.current) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'app/models/auth_source.rb', line 75

def visible?(user=User.current)
  user.admin?
end