Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5e3a99c

Browse files
committedSep 16, 2024
Remove Rails-specific example code
1 parent 222983e commit 5e3a99c

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed
 

‎README

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ SimpleLdapAuthenticator
44
Allows for simple authentication to an LDAP server with a minimum of
55
configuration. Requires either Ruby/LDAP or Net::LDAP.
66

7-
Usage is fairly simple:
7+
Example Usage:
8+
89
require 'simple_ldap_authenticator'
10+
require 'logger'
11+
912
SimpleLdapAuthenticator.servers = %w'dc1.domain.com dc2.domain.com'
1013
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)
2119

22-
github: http://github.com/jeremyevans/simple_ldap_authenticator/tree/master
20+
github: http://github.com/jeremyevans/simple_ldap_authenticator

‎lib/simple_ldap_authenticator.rb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@
1414
# * servers = ['dc1.domain.com', 'dc2.domain.com'] # names/addresses of LDAP servers to use
1515
# * use_ssl = true # for logging in via LDAPS
1616
# * 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
1818
#
1919
# The class is used as a singleton, you are not supposed to create an
2020
# instance of it. For example:
2121
#
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)
3330
class SimpleLdapAuthenticator
3431
@servers = ['127.0.0.1']
3532
@use_ssl = false

0 commit comments

Comments
 (0)
Failed to load comments.