@@ -1,50 +1,51 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class AuthSource < ActiveRecord::Base |
|
19 | 19 | has_many :users |
|
20 | 20 | |
|
21 | 21 | validates_presence_of :name |
|
22 | 22 | validates_uniqueness_of :name |
|
23 |
validates_length_of :name, :host, |
|
|
23 | validates_length_of :name, :host, :maximum => 60 | |
|
24 | validates_length_of :account_password, :maximum => 60, :allow_nil => true | |
|
24 | 25 | validates_length_of :account, :base_dn, :maximum => 255 |
|
25 | 26 | validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30 |
|
26 | 27 | |
|
27 | 28 | def authenticate(login, password) |
|
28 | 29 | end |
|
29 | 30 | |
|
30 | 31 | def test_connection |
|
31 | 32 | end |
|
32 | 33 | |
|
33 | 34 | def auth_method_name |
|
34 | 35 | "Abstract" |
|
35 | 36 | end |
|
36 | 37 | |
|
37 | 38 | # Try to authenticate a user not yet registered against available sources |
|
38 | 39 | def self.authenticate(login, password) |
|
39 | 40 | AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source| |
|
40 | 41 | begin |
|
41 | 42 | logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug? |
|
42 | 43 | attrs = source.authenticate(login, password) |
|
43 | 44 | rescue |
|
44 | 45 | attrs = nil |
|
45 | 46 | end |
|
46 | 47 | return attrs if attrs |
|
47 | 48 | end |
|
48 | 49 | return nil |
|
49 | 50 | end |
|
50 | 51 | end |
General Comments 0
You need to be logged in to leave comments.
Login now