thecore_auth_commons 3.6.3 → 3.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e5604a65938fe43fe952c42c11bdc339ff3217d7d0ca63b659ae5c871c9be5f
4
- data.tar.gz: a7a71c049092955e8e2d47c0117ed62e693d7505ea21cb74ad0d9a3837ab4d13
3
+ metadata.gz: 8882fd092e0638c3dd090eb752eda2a9a0150f6c000e1b4cbf3343da6dbb853d
4
+ data.tar.gz: 2dd4868c8183cdf702fc148a9927d795e93027161f1ef249b7d96ea492168fd6
5
5
  SHA512:
6
- metadata.gz: f13691ce6ca514d637d5031ac1e1555a5a23823e9b669c4c4333d237d8a8c4e0761177932471784597e305cc6a4d46907336921cc096cbf325fb1f93434caa70
7
- data.tar.gz: dec750f7817baa78f77da553e0dc0cc787b4765937ca2ebf6822de8cd23d1f657af4e19450843c2c5d10852028ac644af8f5db6a9bda43d00659f000c411d6f9
6
+ metadata.gz: d7ff0c9f614b4652a44beb92ea26197b148674c7113375f891971fc3f599ad0f224dfca434be127e468580434e52ada696659e0bb26c55f094682a78265f43dd
7
+ data.tar.gz: e5f0cd716bbdb5b8a730b1bece85b3f26d9bd0d658739e66511fc4b4aacad8284068e609ad106e933c595d5c8a0445f31d0a7f099533d15458556df8acff4c04
data/README.md CHANGED
@@ -102,6 +102,8 @@ Multiple servers are supported, ordered by `priority` (ascending). Each server c
102
102
  - `auth_field` — LDAP attribute used as login (e.g. `mail`, `sAMAccountName`)
103
103
  - `name`, `surname`, `phone`, `code` — LDAP attributes mapped to User fields
104
104
 
105
+ `server.test_connection` binds as `admin_user` and returns `success?` and, on failure, a `message` with the reason (no admin credentials, refused bind, unreachable host); it never raises for a connection problem. RailsAdmin's **Test LDAP Server** action shows it.
106
+
105
107
  On LDAP login or import, `memberOf` groups are read; matching group names become `Role` records assigned to the user. Groups named `Administrators`, `Domain Admins`, `Schema Admins`, `Enterprise Admins`, `admins`, or `administrators` also grant `user.admin = true`.
106
108
 
107
109
  Deleting a `LdapServer` record keeps all users whose `auth_source` is `"ldap #{id}"` — same record, same roles — and turns them into local users (`auth_source = "local"`). To log in again they need a local password, set by hand.
@@ -14,8 +14,20 @@ class LdapServer < ApplicationRecord
14
14
  # and need a local password set by hand to log in again.
15
15
  after_destroy :turn_users_into_local_users
16
16
 
17
+ # The outcome of #test_connection: success? and, when it failed, the reason in message.
18
+ ConnectionResult = Data.define(:success, :message) do
19
+ def success? = success
20
+ end
21
+
22
+ # Binds as the admin user and reports whether that worked, and why not. Never raises for a
23
+ # server it cannot reach or bind to: the RailsAdmin test_ldap_server action shows the result.
24
+ # net-ldap raises Net::LDAP::Error for most connection failures, but the bare Errno (a
25
+ # SystemCallError, e.g. ECONNREFUSED) for a single host it cannot connect to.
17
26
  def test_connection
18
- # Test the connection to the LDAP server
27
+ if admin_user.blank? || admin_password.blank?
28
+ return ConnectionResult.new(success: false, message: I18n.t("ldap_server.test_connection.no_admin_credentials"))
29
+ end
30
+
19
31
  ldap = Net::LDAP.new(
20
32
  host: host,
21
33
  port: port,
@@ -26,14 +38,17 @@ class LdapServer < ApplicationRecord
26
38
  password: admin_password
27
39
  }
28
40
  )
29
- # Perform a simple bind to check the connection
30
41
  if ldap.bind
31
- # Connection successful
32
42
  Rails.logger.info "Connection to LDAP server #{host} successful."
43
+ ConnectionResult.new(success: true, message: nil)
33
44
  else
34
- # Connection failed
35
- Rails.logger.info "Connection to LDAP server #{host} failed: #{ldap.get_operation_result.message}"
45
+ reason = ldap.get_operation_result.message
46
+ Rails.logger.info "Connection to LDAP server #{host} failed: #{reason}"
47
+ ConnectionResult.new(success: false, message: reason)
36
48
  end
49
+ rescue Net::LDAP::Error, SystemCallError => e
50
+ Rails.logger.info "Connection to LDAP server #{host} failed: #{e.message}"
51
+ ConnectionResult.new(success: false, message: e.message)
37
52
  end
38
53
 
39
54
  private
@@ -1,4 +1,7 @@
1
1
  en:
2
+ ldap_server:
3
+ test_connection:
4
+ no_admin_credentials: "No admin user and password are configured for this server"
2
5
  devise:
3
6
  sessions:
4
7
  invalid: "Invalid credentials or password."
@@ -1,4 +1,7 @@
1
1
  it:
2
+ ldap_server:
3
+ test_connection:
4
+ no_admin_credentials: "Utente e password di amministrazione non configurati per questo server"
2
5
  devise:
3
6
  sessions:
4
7
  invalid: "Credenziali %{authentication_keys} o password non valide."
@@ -1,3 +1,3 @@
1
1
  module ThecoreAuthCommons
2
- VERSION = "3.6.3".freeze
2
+ VERSION = "3.6.5".freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_auth_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.3
4
+ version: 3.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-11-24 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: net-ldap
@@ -319,6 +320,7 @@ metadata:
319
320
  homepage_uri: https://github.com/gabrieletassoni/thecore_auth_commons
320
321
  source_code_uri: https://github.com/gabrieletassoni/thecore_auth_commons
321
322
  changelog_uri: https://github.com/gabrieletassoni/thecore_auth_commons/blob/master/CHANGELOG.md
323
+ post_install_message:
322
324
  rdoc_options: []
323
325
  require_paths:
324
326
  - lib
@@ -333,7 +335,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
335
  - !ruby/object:Gem::Version
334
336
  version: '0'
335
337
  requirements: []
336
- rubygems_version: 3.6.9
338
+ rubygems_version: 3.5.22
339
+ signing_key:
337
340
  specification_version: 4
338
341
  summary: Common Auth methods and models to be used in thecore components.
339
342
  test_files: []