simple_ldap_authenticator 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +3 -1
  3. data/lib/simple_ldap_authenticator.rb +19 -17
  4. metadata +84 -47
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3a0cd12219f55450a7360afd838042eeeb7c96914fa01e7f573246c8de9bec8c
4
+ data.tar.gz: 38e42cc1bd4bc35bf8f5d7f71317d53bf0aa816041a5198aaaa8abe06bddc954
5
+ SHA512:
6
+ metadata.gz: fc4aa226b58a7d8889e3049ba134c194466951e4691a9a3be58c083460dec02295632a49cfe8bd274612d8fe684426d1b0c02f3eec6d2a312a2e26eca4cf1d4f
7
+ data.tar.gz: 6d95e78ff27cce08a1f7cebd9c95499701efffcdae602243079763ed085936215255318586d4187d5e0f4e2c9e60a8dfed829436f1c6f9e8ff8d9243e150dd10
data/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2004-2007 Jeremy Evans
1
+ Copyright (c) 2006-2022 Jeremy Evans
2
+
3
+ test/ldapserver.rb Copyright (c) 2006-2011 by Francis Cianfrocca and other contributors.
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
6
  of this software and associated documentation files (the "Software"), to deal
@@ -16,7 +16,7 @@
16
16
  # * port = 3289 # instead of 389 for LDAP or 636 for LDAPS
17
17
  # * logger = RAILS_DEFAULT_LOGGER # for logging authentication successes/failures
18
18
  #
19
- # The class is used as a global variable, you are not supposed to create an
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
22
  # require 'simple_ldap_authenticator'
@@ -31,17 +31,19 @@
31
31
  # end
32
32
  # end
33
33
  class SimpleLdapAuthenticator
34
+ @servers = ['127.0.0.1']
35
+ @use_ssl = false
36
+ @login_format = '%s'
37
+
34
38
  class << self
35
- @servers = ['127.0.0.1']
36
- @use_ssl = false
37
- @login_format = '%s'
38
- attr_accessor :servers, :use_ssl, :port, :login_format, :logger, :connection, :ldap_library
39
+ attr_accessor :servers, :use_ssl, :login_format, :logger, :ldap_library
40
+ attr_writer :port, :connection
39
41
 
40
42
  # Load the required LDAP library, either 'ldap' or 'net/ldap'
41
43
  def load_ldap_library
42
44
  return if @ldap_library_loaded
43
- if ldap_library
44
- if ldap_library == 'net/ldap'
45
+ if @ldap_library
46
+ if @ldap_library == 'net/ldap'
45
47
  require 'net/ldap'
46
48
  else
47
49
  require 'ldap'
@@ -51,10 +53,10 @@ class SimpleLdapAuthenticator
51
53
  begin
52
54
  require 'ldap'
53
55
  require 'ldap/control'
54
- ldap_library = 'ldap'
56
+ @ldap_library = 'ldap'
55
57
  rescue LoadError
56
58
  require 'net/ldap'
57
- ldap_library = 'net/ldap'
59
+ @ldap_library = 'net/ldap'
58
60
  end
59
61
  end
60
62
  @ldap_library_loaded = true
@@ -98,14 +100,14 @@ class SimpleLdapAuthenticator
98
100
  connection.authenticate(login_format % login.to_s, password.to_s)
99
101
  begin
100
102
  if connection.bind
101
- logger.info("Authenticated #{login.to_s} by #{server}") if logger
102
- true
103
- else
104
- logger.info("Error attempting to authenticate #{login.to_s} by #{server}: #{connection.get_operation_result.code} #{connection.get_operation_result.message}") if logger
105
- switch_server unless connection.get_operation_result.code == 49
106
- false
107
- end
108
- rescue Net::LDAP::LdapError => error
103
+ logger.info("Authenticated #{login.to_s} by #{server}") if logger
104
+ true
105
+ else
106
+ logger.info("Error attempting to authenticate #{login.to_s} by #{server}: #{connection.get_operation_result.code} #{connection.get_operation_result.message}") if logger
107
+ switch_server unless connection.get_operation_result.code == 49
108
+ false
109
+ end
110
+ rescue Net::LDAP::Error, SocketError, SystemCallError => error
109
111
  logger.info("Error attempting to authenticate #{login.to_s} by #{server}: #{error.message}") if logger
110
112
  switch_server
111
113
  false
metadata CHANGED
@@ -1,72 +1,109 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: simple_ldap_authenticator
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 1
10
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jeremy Evans
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-08-03 00:00:00 -07:00
19
- default_executable:
20
- dependencies: []
21
-
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest-global_expectations
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: eventmachine
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: net-ldap
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-ldap
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
22
69
  description:
23
70
  email: code@jeremyevans.net
24
71
  executables: []
25
-
26
72
  extensions: []
27
-
28
- extra_rdoc_files:
73
+ extra_rdoc_files:
29
74
  - LICENSE
30
- files:
31
- - README
75
+ files:
32
76
  - LICENSE
77
+ - README
33
78
  - lib/simple_ldap_authenticator.rb
34
- has_rdoc: true
35
79
  homepage:
36
80
  licenses: []
37
-
81
+ metadata:
82
+ bug_tracker_uri: https://github.com/jeremyevans/simple_ldap_authenticator/issues
83
+ changelog_uri: https://github.com/jeremyevans/simple_ldap_authenticator/blob/master/CHANGELOG
84
+ mailing_list_uri: https://github.com/jeremyevans/simple_ldap_authenticator/discussions
85
+ source_code_uri: https://github.com/jeremyevans/simple_ldap_authenticator
38
86
  post_install_message:
39
- rdoc_options:
40
- - --inline-source
41
- - --line-numbers
87
+ rdoc_options:
88
+ - "--inline-source"
89
+ - "--line-numbers"
42
90
  - README
43
91
  - lib
44
- require_paths:
92
+ require_paths:
45
93
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
47
- none: false
48
- requirements:
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
49
96
  - - ">="
50
- - !ruby/object:Gem::Version
51
- hash: 3
52
- segments:
53
- - 0
54
- version: "0"
55
- required_rubygems_version: !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
58
101
  - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
64
104
  requirements: []
65
-
66
- rubyforge_project:
67
- rubygems_version: 1.3.7
105
+ rubygems_version: 3.3.7
68
106
  signing_key:
69
- specification_version: 3
107
+ specification_version: 4
70
108
  summary: Easy authentication to an LDAP server(s)
71
109
  test_files: []
72
-