Class: AuthSource

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Redmine::Ciphering, Redmine::SubclassFactory
Defined in:
app/models/auth_source.rb

Overview

Since:

  • 0.4.0

Direct Known Subclasses

AuthSourceLdap

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Redmine::Ciphering

cipher_key, decrypt_text, encrypt_text, logger

Class Method Details

.allow_password_changes?Boolean

Does this auth source backend allow password changes?

Returns:

  • (Boolean)

Since:

  • 1.0.0



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

def self.allow_password_changes?
  false
end

.authenticate(login, password) ⇒ Object

Try to authenticate a user not yet registered against available sources



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

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

Since:

  • 2.3.0



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/models/auth_source.rb', line 56

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

Since:

  • 1.2.0



44
45
46
# File 'app/models/auth_source.rb', line 44

def 
  read_ciphered_attribute(:account_password)
end

#account_password=(arg) ⇒ Object

Since:

  • 1.2.0



48
49
50
# File 'app/models/auth_source.rb', line 48

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

#allow_password_changes?Boolean

Returns:

  • (Boolean)

Since:

  • 1.0.0



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

def allow_password_changes?
  self.class.allow_password_changes?
end

#auth_method_nameObject



40
41
42
# File 'app/models/auth_source.rb', line 40

def auth_method_name
  "Abstract"
end

#authenticate(login, password) ⇒ Object



34
35
# File 'app/models/auth_source.rb', line 34

def authenticate(, password)
end

#searchable?Boolean

Returns:

  • (Boolean)

Since:

  • 2.3.0



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

def searchable?
  false
end

#test_connectionObject



37
38
# File 'app/models/auth_source.rb', line 37

def test_connection
end