@@ -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 | 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, :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 | 27 | def authenticate(login, password) |
|
25 | 28 | end |
|
26 | 29 | |
|
27 | 30 | def test_connection |
|
28 | 31 | end |
|
29 | 32 | |
|
30 | 33 | def auth_method_name |
|
31 | 34 | "Abstract" |
|
32 | 35 | end |
|
33 | 36 | |
|
34 | 37 | # Try to authenticate a user not yet registered against available sources |
|
35 | 38 | def self.authenticate(login, password) |
|
36 | 39 | AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source| |
|
37 | 40 | begin |
|
38 | 41 | logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug? |
|
39 | 42 | attrs = source.authenticate(login, password) |
|
40 | 43 | rescue |
|
41 | 44 | attrs = nil |
|
42 | 45 | end |
|
43 | 46 | return attrs if attrs |
|
44 | 47 | end |
|
45 | 48 | return nil |
|
46 | 49 | end |
|
47 | 50 | end |
General Comments 0
You need to be logged in to leave comments.
Login now