Expand file tree Collapse file tree 2 files changed +19
-24
lines changed Original file line number Diff line number Diff line change @@ -4,19 +4,17 @@ SimpleLdapAuthenticator
4
4
Allows for simple authentication to an LDAP server with a minimum of
5
5
configuration. Requires either Ruby/LDAP or Net::LDAP.
6
6
7
- Usage is fairly simple:
7
+ Example Usage:
8
+
8
9
require 'simple_ldap_authenticator'
10
+ require 'logger'
11
+
9
12
SimpleLdapAuthenticator.servers = %w'dc1.domain.com dc2.domain.com'
10
13
SimpleLdapAuthenticator.use_ssl = true
11
- SimpleLdapAuthenticator.login_format = '%s @domain.com'
12
- SimpleLdapAuthenticator.logger = RAILS_DEFAULT_LOGGER
13
- class LoginController < ApplicationController
14
- def login
15
- return redirect_to(:action=>'try_again') unless \
16
- SimpleLdapAuthenticator.valid?(params[:username], \
17
- params[:password])
18
- session[:username] = params[:username]
19
- end
20
- end
14
+ SimpleLdapAuthenticator.login_format = '%s@domain.com'
15
+ SimpleLdapAuthenticator.logger = Logger.new($stdout)
16
+
17
+ SimpleLdapAuthenticator.valid?(username, password)
18
+ # => true or false (or raise if there is an issue connecting to the server)
21
19
22
- github: http://github.com/jeremyevans/simple_ldap_authenticator/tree/master
20
+ github: http://github.com/jeremyevans/simple_ldap_authenticator
Original file line number Diff line number Diff line change 14
14
# * servers = ['dc1.domain.com', 'dc2.domain.com'] # names/addresses of LDAP servers to use
15
15
# * use_ssl = true # for logging in via LDAPS
16
16
# * port = 3289 # instead of 389 for LDAP or 636 for LDAPS
17
- # * logger = RAILS_DEFAULT_LOGGER # for logging authentication successes/failures
17
+ # * logger = Logger.new($stdout) # for logging authentication successes/failures
18
18
#
19
19
# The class is used as a singleton, you are not supposed to create an
20
20
# instance of it. For example:
21
21
#
22
- # require 'simple_ldap_authenticator'
23
- # SimpleLdapAuthenticator.servers = %w'dc1.domain.com dc2.domain.com'
24
- # SimpleLdapAuthenticator.use_ssl = true
25
- # SimpleLdapAuthenticator.login_format = '%s@domain.com'
26
- # SimpleLdapAuthenticator.logger = RAILS_DEFAULT_LOGGER
27
- # class LoginController < ApplicationController
28
- # def login
29
- # return redirect_to(:action=>'try_again') unless SimpleLdapAuthenticator.valid?(params[:username], params[:password])
30
- # session[:username] = params[:username]
31
- # end
32
- # end
22
+ # require 'simple_ldap_authenticator'
23
+ #
24
+ # SimpleLdapAuthenticator.servers = %w'dc1.domain.com dc2.domain.com'
25
+ # SimpleLdapAuthenticator.use_ssl = true
26
+ # SimpleLdapAuthenticator.login_format = '%s@domain.com'
27
+ #
28
+ # SimpleLdapAuthenticator.valid?(username, password)
29
+ # # => true or false (or raise if there is an issue connecting to the server)
33
30
class SimpleLdapAuthenticator
34
31
@servers = [ '127.0.0.1' ]
35
32
@use_ssl = false
0 commit comments