Project

General

Profile

Feature #9216 » auth_ldap_failover.patch

Julian Faude, 2013-06-19 01:07

View differences:

app/views/auth_sources/index.html.erb (working copy)
8 8
  <thead><tr>
9 9
    <th><%=l(:field_name)%></th>
10 10
    <th><%=l(:field_type)%></th>
11
    <th><%=l(:field_host)%></th>
11
    <th><%=l(:field_hosts)%></th>
12 12
    <th><%=l(:label_user_plural)%></th>
13 13
    <th></th>
14 14
  </tr></thead>
......
17 17
  <tr id="auth-source-<%= source.id %>" class="<%= cycle("odd", "even") %>">
18 18
    <td><%= link_to(h(source.name), :action => 'edit', :id => source)%></td>
19 19
    <td align="center"><%= h source.auth_method_name %></td>
20
    <td align="center"><%= h source.host %></td>
20
    <td align="center"><%= h source.hosts %></td>
21 21
    <td align="center"><%= h source.users.count %></td>
22 22
    <td class="buttons">
23 23
      <%= link_to l(:button_test), try_connection_auth_source_path(source), :class => 'icon icon-test' %>
app/views/auth_sources/_form_auth_source_ldap.html.erb (working copy)
2 2

  
3 3
<div class="box tabular">
4 4
  <p><%= f.text_field :name, :required => true %></p>
5
  <p><%= f.text_field :host, :required => true %></p>
5
  <p><%= f.text_field :hosts, :size => 60, :required => true %></p>
6 6
  <p><%= f.text_field :port, :required => true, :size => 6 %> <%= f.check_box :tls, :no_label => true %> LDAPS</p>
7 7
  <p><%= f.text_field :account %></p>
8 8
  <p><%= f.password_field :account_password, :label => :field_password,
app/models/auth_source_ldap.rb (working copy)
20 20
require 'timeout'
21 21

  
22 22
class AuthSourceLdap < AuthSource
23
  validates_presence_of :host, :port, :attr_login
24
  validates_length_of :name, :host, :maximum => 60, :allow_nil => true
23
  validates_presence_of :hosts, :port, :attr_login
24
  validates_length_of :name, :maximum => 60, :allow_nil => true
25
  validates_length_of :hosts, :maximum => 120, :allow_nil => true
25 26
  validates_length_of :account, :account_password, :base_dn, :filter, :maximum => 255, :allow_blank => true
26 27
  validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
27 28
  validates_numericality_of :port, :only_integer => true
......
51 52

  
52 53
  # test the connection to the LDAP
53 54
  def test_connection
54
    with_timeout do
55
      ldap_con = initialize_ldap_con(self.account, self.account_password)
56
      ldap_con.open { }
57
    end
58
  rescue Net::LDAP::LdapError => e
59
    raise AuthSourceException.new(e.message)
55
    initialize_ldap_con(self.account, self.account_password)
60 56
  end
61 57

  
62 58
  def auth_method_name
......
130 126
  end
131 127

  
132 128
  def initialize_ldap_con(ldap_user, ldap_password)
133
    options = { :host => self.host,
129
    options = { :host => "",
134 130
                :port => self.port,
135 131
                :encryption => (self.tls ? :simple_tls : nil)
136 132
              }
137 133
    options.merge!(:auth => { :method => :simple, :username => ldap_user, :password => ldap_password }) unless ldap_user.blank? && ldap_password.blank?
138
    Net::LDAP.new options
134

  
135
    m = nil
136
    self.hosts.split(",").reverse.each do |host|
137
      begin
138
        options[:host] = host
139
        ldap_con = Net::LDAP.new options
140
        with_timeout do
141
          ldap_con.open { }
142
        end
143
        return ldap_con
144
      rescue Exception => e
145
        logger.warn e.message if logger && logger.warn?
146
        m = e.message
147
      end
148
    end
149
    raise AuthSourceException.new(m)
139 150
  end
140 151

  
141 152
  def get_user_attributes_from_ldap_entry(entry)
config/locales/uk.yml (working copy)
226 226
  field_password_confirmation: Підтвердження
227 227
  field_version: Версія
228 228
  field_type: Тип
229
  field_host: Машина
229
  field_hosts: Машина
230 230
  field_port: Порт
231 231
  field_account: Обліковий запис
232 232
  field_base_dn: Базове відмітне ім'я
config/locales/pt-BR.yml (working copy)
258 258
  field_password_confirmation: Confirmação
259 259
  field_version: Versão
260 260
  field_type: Tipo
261
  field_host: Servidor
261
  field_hosts: Servidor
262 262
  field_port: Porta
263 263
  field_account: Conta
264 264
  field_base_dn: DN Base
config/locales/fa.yml (working copy)
261 261
  field_password_confirmation: بررسی گذرواژه
262 262
  field_version: نگارش
263 263
  field_type: گونه
264
  field_host: میزبان
264
  field_hosts: میزبان
265 265
  field_port: درگاه
266 266
  field_account: حساب
267 267
  field_base_dn: DN پایه
config/locales/bg.yml (working copy)
270 270
  field_password_confirmation: Потвърждение
271 271
  field_version: Версия
272 272
  field_type: Тип
273
  field_host: Хост
273
  field_hosts: Хост
274 274
  field_port: Порт
275 275
  field_account: Профил
276 276
  field_base_dn: Base DN
config/locales/ja.yml (working copy)
291 291
  field_password_confirmation: パスワードの確認
292 292
  field_version: バージョン
293 293
  field_type: タイプ
294
  field_host: ホスト
294
  field_hosts: ホスト
295 295
  field_port: ポート
296 296
  field_account: アカウント
297 297
  field_base_dn: 検索範囲
config/locales/fi.yml (working copy)
257 257
  field_password_confirmation: Vahvistus
258 258
  field_version: Versio
259 259
  field_type: Tyyppi
260
  field_host: Verkko-osoite
260
  field_hosts: Verkko-osoite
261 261
  field_port: Portti
262 262
  field_account: Tili
263 263
  field_base_dn: Base DN
config/locales/bs.yml (working copy)
250 250
  field_password_confirmation: Potvrda
251 251
  field_version: Verzija
252 252
  field_type: Tip
253
  field_host: Host
253
  field_hosts: Host
254 254
  field_port: Port
255 255
  field_account: Korisnički račun
256 256
  field_base_dn: Base DN
config/locales/fr.yml (working copy)
277 277
  field_password_confirmation: Confirmation
278 278
  field_version: Version
279 279
  field_type: Type
280
  field_host: Hôte
280
  field_hosts: Hôte
281 281
  field_port: Port
282 282
  field_account: Compte
283 283
  field_base_dn: Base DN
config/locales/nl.yml (working copy)
229 229
  field_fixed_version: Versie
230 230
  field_hide_mail: Verberg mijn e-mailadres
231 231
  field_homepage: Homepage
232
  field_host: Host
232
  field_hosts: Host
233 233
  field_hours: Uren
234 234
  field_identifier: Identificatiecode
235 235
  field_is_closed: Issue gesloten
config/locales/no.yml (working copy)
226 226
  field_password_confirmation: Bekreft passord
227 227
  field_version: Versjon
228 228
  field_type: Type
229
  field_host: Vert
229
  field_hosts: Vert
230 230
  field_port: Port
231 231
  field_account: Konto
232 232
  field_base_dn: Base DN
config/locales/vi.yml (working copy)
289 289
  field_password_confirmation: Nhập lại mật khẩu
290 290
  field_version: Phiên bản
291 291
  field_type: Kiểu
292
  field_host: Host
292
  field_hosts: Host
293 293
  field_port: Cổng
294 294
  field_account: Tài khoản
295 295
  field_base_dn: Base DN
config/locales/ro.yml (working copy)
234 234
  field_password_confirmation: Confirmare
235 235
  field_version: Versiune
236 236
  field_type: Tip
237
  field_host: Gazdă
237
  field_hosts: Gazdă
238 238
  field_port: Port
239 239
  field_account: Cont
240 240
  field_base_dn: Base DN
config/locales/zh.yml (working copy)
265 265
  field_password_confirmation: 确认
266 266
  field_version: 版本
267 267
  field_type: 类型
268
  field_host: 主机
268
  field_hosts: 主机
269 269
  field_port: 端口
270 270
  field_account: 帐号
271 271
  field_base_dn: Base DN
config/locales/ca.yml (working copy)
262 262
  field_password_confirmation: Confirmació
263 263
  field_version: Versió
264 264
  field_type: Tipus
265
  field_host: Ordinador
265
  field_hosts: Ordinador
266 266
  field_port: Port
267 267
  field_account: Compte
268 268
  field_base_dn: Base DN
config/locales/ru.yml (working copy)
332 332
  field_fixed_version: Версия
333 333
  field_hide_mail: Скрывать мой email
334 334
  field_homepage: Стартовая страница
335
  field_host: Компьютер
335
  field_hosts: Компьютер
336 336
  field_hours: час(а,ов)
337 337
  field_identifier: Уникальный идентификатор
338 338
  field_identity_url: OpenID URL
config/locales/gl.yml (working copy)
258 258
  field_fixed_version: Versión prevista
259 259
  field_hide_mail: Ocultar a miña dirección de correo
260 260
  field_homepage: Sitio web
261
  field_host: Anfitrión
261
  field_hosts: Anfitrión
262 262
  field_hours: Horas
263 263
  field_identifier: Identificador
264 264
  field_is_closed: Petición resolta
config/locales/cs.yml (working copy)
266 266
  field_password_confirmation: Potvrzení
267 267
  field_version: Verze
268 268
  field_type: Typ
269
  field_host: Host
269
  field_hosts: Host
270 270
  field_port: Port
271 271
  field_account: Účet
272 272
  field_base_dn: Base DN
config/locales/ko.yml (working copy)
290 290
  field_password_confirmation: 비밀번호 확인
291 291
  field_version: 버전
292 292
  field_type: 방식
293
  field_host: 호스트
293
  field_hosts: 호스트
294 294
  field_port: 포트
295 295
  field_account: 계정
296 296
  field_base_dn: 기본 DN
config/locales/sk.yml (working copy)
232 232
  field_password_confirmation: Potvrdenie
233 233
  field_version: Verzia
234 234
  field_type: Typ
235
  field_host: Host
235
  field_hosts: Host
236 236
  field_port: Port
237 237
  field_account: Účet
238 238
  field_base_dn: Base DN
config/locales/sl.yml (working copy)
236 236
  field_password_confirmation: Potrditev
237 237
  field_version: Verzija
238 238
  field_type: Tip
239
  field_host: Gostitelj
239
  field_hosts: Gostitelj
240 240
  field_port: Vrata
241 241
  field_account: Račun
242 242
  field_base_dn: Bazni DN
config/locales/sr-YU.yml (working copy)
262 262
  field_password_confirmation: Potvrda lozinke
263 263
  field_version: Verzija
264 264
  field_type: Tip
265
  field_host: Glavni računar
265
  field_hosts: Glavni računar
266 266
  field_port: Port
267 267
  field_account: Korisnički nalog
268 268
  field_base_dn: Bazni DN
config/locales/sq.yml (working copy)
267 267
  field_password_confirmation: Konfirmim Fjalekalimi
268 268
  field_version: Versioni
269 269
  field_type: Type
270
  field_host: Host
270
  field_hosts: Host
271 271
  field_port: Port
272 272
  field_account: Llogaria
273 273
  field_base_dn: Base DN
config/locales/da.yml (working copy)
249 249
  field_password_confirmation: Bekræft
250 250
  field_version: Version
251 251
  field_type: Type
252
  field_host: Vært
252
  field_hosts: Vært
253 253
  field_port: Port
254 254
  field_account: Kode
255 255
  field_base_dn: Base DN
config/locales/sr.yml (working copy)
260 260
  field_password_confirmation: Потврда лозинке
261 261
  field_version: Верзија
262 262
  field_type: Тип
263
  field_host: Главни рачунар
263
  field_hosts: Главни рачунар
264 264
  field_port: Порт
265 265
  field_account: Кориснички налог
266 266
  field_base_dn: Базни DN
config/locales/sv.yml (working copy)
312 312
  field_password_confirmation: Bekräfta lösenord
313 313
  field_version: Version
314 314
  field_type: Typ
315
  field_host: Värddator
315
  field_hosts: Värddator
316 316
  field_port: Port
317 317
  field_account: Konto
318 318
  field_base_dn: Bas-DN
config/locales/en-GB.yml (working copy)
266 266
  field_password_confirmation: Confirmation
267 267
  field_version: Version
268 268
  field_type: Type
269
  field_host: Host
269
  field_hosts: Host
270 270
  field_port: Port
271 271
  field_account: Account
272 272
  field_base_dn: Base DN
config/locales/de.yml (working copy)
53 53
        one: 'etwa 1 Stunde'
54 54
        other: 'etwa %{count} Stunden'
55 55
      x_hours:
56
        one:   "1 Stunde"
57
        other: "%{count} Stunden"
56
        one:   "1 hour"
57
        other: "%{count} hours"
58 58
      x_days:
59 59
        one: '1 Tag'
60 60
        other: '%{count} Tagen'
......
312 312
  field_group_by: Gruppiere Ergebnisse nach
313 313
  field_hide_mail: E-Mail-Adresse nicht anzeigen
314 314
  field_homepage: Projekt-Homepage
315
  field_host: Host
315
  field_hosts: Hosts
316 316
  field_hours: Stunden
317 317
  field_identifier: Kennung
318 318
  field_identity_url: OpenID-URL
config/locales/he.yml (working copy)
265 265
  field_password_confirmation: אישור
266 266
  field_version: גירסה
267 267
  field_type: סוג
268
  field_host: שרת
268
  field_hosts: שרת
269 269
  field_port: פורט
270 270
  field_account: חשבון
271 271
  field_base_dn: בסיס DN
config/locales/zh-TW.yml (working copy)
354 354
  field_password_confirmation: 確認新密碼
355 355
  field_version: 版本
356 356
  field_type: Type
357
  field_host: Host
357
  field_hosts: Host
358 358
  field_port: 連接埠
359 359
  field_account: 帳戶
360 360
  field_base_dn: Base DN
config/locales/hr.yml (working copy)
247 247
  field_password_confirmation: Potvrda zaporke
248 248
  field_version: Verzija
249 249
  field_type: Tip
250
  field_host: Host
250
  field_hosts: Host
251 251
  field_port: Port
252 252
  field_account: Racun
253 253
  field_base_dn: Osnovni DN
config/locales/pl.yml (working copy)
250 250
  field_fixed_version: Wersja docelowa
251 251
  field_hide_mail: Ukryj mój adres e-mail
252 252
  field_homepage: Strona www
253
  field_host: Host
253
  field_hosts: Host
254 254
  field_hours: Godzin
255 255
  field_identifier: Identyfikator
256 256
  field_is_closed: Zagadnienie zamknięte
config/locales/th.yml (working copy)
232 232
  field_password_confirmation: ยืนยันรหัสผ่าน
233 233
  field_version: รุ่น
234 234
  field_type: ชนิด
235
  field_host: โฮสต์
235
  field_hosts: โฮสต์
236 236
  field_port: พอร์ต
237 237
  field_account: บัญชี
238 238
  field_base_dn: Base DN
config/locales/hu.yml (working copy)
255 255
  field_password_confirmation: Megerősítés
256 256
  field_version: Verzió
257 257
  field_type: Típus
258
  field_host: Kiszolgáló
258
  field_hosts: Kiszolgáló
259 259
  field_port: Port
260 260
  field_account: Felhasználói fiók
261 261
  field_base_dn: Base DN
config/locales/lt.yml (working copy)
323 323
  field_password_confirmation: Patvirtinimas
324 324
  field_version: Versija
325 325
  field_type: Tipas
326
  field_host: Pagrindinis kompiuteris
326
  field_hosts: Pagrindinis kompiuteris
327 327
  field_port: Prievadas
328 328
  field_account: Paskyra
329 329
  field_base_dn: Bazinis skiriamasis vardas (base DN)
config/locales/lv.yml (working copy)
246 246
  field_password_confirmation: Paroles apstiprinājums
247 247
  field_version: Versija
248 248
  field_type: Tips
249
  field_host: Hosts
249
  field_hosts: Hosts
250 250
  field_port: Ports
251 251
  field_account: Konts
252 252
  field_base_dn: Base DN
config/locales/pt.yml (working copy)
246 246
  field_password_confirmation: Confirmação
247 247
  field_version: Versão
248 248
  field_type: Tipo
249
  field_host: Servidor
249
  field_hosts: Servidor
250 250
  field_port: Porta
251 251
  field_account: Conta
252 252
  field_base_dn: Base DN
config/locales/tr.yml (working copy)
256 256
  field_password_confirmation: Onay
257 257
  field_version: Sürüm
258 258
  field_type: Tip
259
  field_host: Host
259
  field_hosts: Host
260 260
  field_port: Port
261 261
  field_account: Hesap
262 262
  field_base_dn: Base DN
config/locales/id.yml (working copy)
247 247
  field_password_confirmation: Konfirmasi
248 248
  field_version: Versi
249 249
  field_type: Tipe
250
  field_host: Host
250
  field_hosts: Host
251 251
  field_port: Port
252 252
  field_account: Akun
253 253
  field_base_dn: Base DN
config/locales/el.yml (working copy)
246 246
  field_password_confirmation: Επιβεβαίωση
247 247
  field_version: Έκδοση
248 248
  field_type: Τύπος
249
  field_host: Κόμβος
249
  field_hosts: Κόμβος
250 250
  field_port: Θύρα
251 251
  field_account: Λογαριασμός
252 252
  field_base_dn: Βάση DN
config/locales/ar.yml (working copy)
264 264
  field_password_confirmation: تأكيد
265 265
  field_version: إصدار
266 266
  field_type: نوع
267
  field_host: المضيف
267
  field_hosts: المضيف
268 268
  field_port: المنفذ
269 269
  field_account: الحساب
270 270
  field_base_dn: DN قاعدة
config/locales/en.yml (working copy)
269 269
  field_password_confirmation: Confirmation
270 270
  field_version: Version
271 271
  field_type: Type
272
  field_host: Host
272
  field_hosts: Hosts
273 273
  field_port: Port
274 274
  field_account: Account
275 275
  field_base_dn: Base DN
config/locales/es.yml (working copy)
283 283
  field_fixed_version: Versión prevista
284 284
  field_hide_mail: Ocultar mi dirección de correo
285 285
  field_homepage: Sitio web
286
  field_host: Anfitrión
286
  field_hosts: Anfitrión
287 287
  field_hours: Horas
288 288
  field_identifier: Identificador
289 289
  field_is_closed: Petición resuelta
config/locales/mk.yml (working copy)
260 260
  field_password_confirmation: Потврда
261 261
  field_version: Верзија
262 262
  field_type: Тип
263
  field_host: Хост
263
  field_hosts: Хост
264 264
  field_port: Порт
265 265
  field_account: Account
266 266
  field_base_dn: Base DN
config/locales/et.yml (working copy)
284 284
  field_password_confirmation: "Kinnitus"
285 285
  field_version: "Versioon"
286 286
  field_type: "Tüüp"
287
  field_host: "Server"
287
  field_hosts: "Server"
288 288
  field_port: "Port"
289 289
  field_account: "Konto"
290 290
  field_base_dn: "Baas DN"
config/locales/eu.yml (working copy)
254 254
  field_password_confirmation: Berrespena
255 255
  field_version: Bertsioa
256 256
  field_type: Mota
257
  field_host: Ostalaria
257
  field_hosts: Ostalaria
258 258
  field_port: Portua
259 259
  field_account: Kontua
260 260
  field_base_dn: Base DN
config/locales/az.yml (working copy)
322 322
  field_fixed_version: Variant
323 323
  field_hide_mail: E-poçtumu gizlət
324 324
  field_homepage: Başlanğıc səhifə
325
  field_host: Kompyuter
325
  field_hosts: Kompyuter
326 326
  field_hours: saat
327 327
  field_identifier: Unikal identifikator
328 328
  field_identity_url: OpenID URL
config/locales/mn.yml (working copy)
252 252
  field_password_confirmation: Баталгаажуулах
253 253
  field_version: Хувилбар
254 254
  field_type: Төрөл
255
  field_host: Хост
255
  field_hosts: Хост
256 256
  field_port: Порт
257 257
  field_account: Данс
258 258
  field_base_dn: Үндсэн ДН
config/locales/it.yml (working copy)
228 228
  field_password_confirmation: Conferma
229 229
  field_version: Versione
230 230
  field_type: Tipo
231
  field_host: Host
231
  field_hosts: Host
232 232
  field_port: Porta
233 233
  field_account: Utente
234 234
  field_base_dn: DN base
    (1-1/1)