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