thecore_ui_rails_admin 3.5.3 → 3.5.4

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: 3dd34d8d6ad24e02e889b0e4892a0fd60764e9472624f3fbb653fce8ec3dd814
4
- data.tar.gz: 62c27cd585b7dd4c57aca48cd4bc5eee7b28833df338aab17f56c242a61a1330
3
+ metadata.gz: 2e25d04c3b840bf878381f5e3a3e6d18bdd7dc5d22f1f50f26c8e3853c8406ba
4
+ data.tar.gz: 700433ded03b3f772826542c0538cb208e6e6948c852838c97e74fcfa494d40d
5
5
  SHA512:
6
- metadata.gz: c3b3728e02262a11b694b83968904e0effab6bb598791325c06049ffdedf6c14f71a6ea246b9d4384e32d53ae16436cfa38c03d23d1f6e4d7ca679e452899f26
7
- data.tar.gz: a391171b59b1a07d6f148004b01db14e701def63fb6603e9aab239e6c0e2b741c8a8a8d7a6ab76bc8af4b221a1656bccd2f815e0118e15fc9c66abff65775687
6
+ metadata.gz: 9134ec81516e589c99927f777a95a93afb4e8536ebb4c819be6fa5c31bbbfe73c90a72918b9178d49c667396834c7f411f46d0dc8acd618ce0eba53fcb12f602
7
+ data.tar.gz: 4c49d4697527d85773c940f2e5560acc34200e7b8d7cea001bedfc085ca3d1b8a9f8bf9ece6f76c77840b42bf3f844a0ebdf7b325e487b2433a683ba60a71dfe
@@ -1,10 +1,59 @@
1
- <!-- Logic to test LDAP server connection -->
2
- <% if @ldap_server_test %>
3
- <div class="alert alert-success">
4
- <%=@message%>
1
+ <!-- Show the LDAP server connection status -->
2
+ <div class="p-3 mb-2 bg-<%=@status%> text-white">
3
+ <%=@message%>
4
+ </div>
5
+
6
+ <!-- Show an informative and helpful section with the information about the LDAP server configuration -->
7
+ <!-- The LdapServer has these fields: host, port, admin_dn, admin_password, base_dn, ssl_enabled, auth_field -->
8
+ <div class="card">
9
+ <div class="card-header">
10
+ <h5>LDAP Server Configuration</h5>
5
11
  </div>
6
- <% else %>
7
- <div class="alert alert-danger">
8
- <%=@message%>
12
+ <div class="card-body">
13
+ <p><strong>Host:</strong> <%= @ldap.host %></p>
14
+ <p><strong>Port:</strong> <%= @ldap.port %></p>
15
+ <p><strong>Admin DN:</strong> <%= @ldap.admin_user %></p>
16
+ <p><strong>Base DN:</strong> <%= @ldap.base_dn %></p>
17
+ <p><strong>SSL Enabled:</strong> <%= @ldap.use_ssl ? 'Yes' : 'No' %></p>
18
+ <p><strong>Authentication Field:</strong> <%= @ldap.auth_field %></p>
9
19
  </div>
10
- <% end %>
20
+ </div>
21
+
22
+ <!-- Form to test LDAP connection with custom credentials -->
23
+ <div class="card mt-4">
24
+ <div class="card-header">
25
+ <h5>Test LDAP Connection with Custom Credentials</h5>
26
+ </div>
27
+ <div class="card-body">
28
+ <%= form_with url: rails_admin.test_ldap_server_path, method: :post, local: true do |form| %>
29
+ <div class="mb-3">
30
+ <%= form.label :email, 'Email', class: 'form-label' %>
31
+ <%= form.email_field :email, class: 'form-control', required: true %>
32
+ </div>
33
+ <div class="mb-3">
34
+ <%= form.label :password, 'Password', class: 'form-label' %>
35
+ <%= form.password_field :password, class: 'form-control', required: true %>
36
+ </div>
37
+ <%= form.submit 'Test Connection', class: 'btn btn-primary' %>
38
+ <% end %>
39
+ </div>
40
+ </div>
41
+
42
+ <!-- In the @ldap_user variable, if present, show the details of the authenticated user -->
43
+ <% if @ldap_user %>
44
+ <div class="card mt-4">
45
+ <div class="card-header">
46
+ <h5>Authenticated LDAP User Details</h5>
47
+ </div>
48
+ <div class="card-body">
49
+ <p><strong>DN:</strong> <%= @ldap_user.dn %></p>
50
+ <p><strong>Attributes:</strong></p>
51
+ <ul>
52
+ <% @ldap_user.each_attribute do |key, values| %>
53
+ <li><strong><%= key %>:</strong> <%= values.join(', ') %></li>
54
+ <% end %>
55
+ </ul>
56
+
57
+ </div>
58
+ </div>
59
+ <% end %>
@@ -1,30 +1,48 @@
1
1
  RailsAdmin::Config::Actions.add_action "test_ldap_server", :base, :member do
2
-
3
- link_icon 'fas fa-circle-check'
4
-
5
- http_methods [:get]
2
+ link_icon "fas fa-circle-check"
6
3
 
7
- # Visible only for the User model
8
- visible do
9
- bindings[:object].is_a?(::LdapServer)
10
- end
11
- # Adding the controller which is needed to compute calls from the ui
12
- controller do
13
- proc do
14
- # From the UI the user can test if the ldap server is reachable and receive a response
15
- if request.get?
16
- ldap = ::LdapServer.find(@object.id)
17
- begin
18
- ldap.test_connection
19
-
20
- flash[:success] = @message = I18n.t("admin.actions.test_ldap_server.success")
21
- rescue => e
22
- flash[:error] = @message = I18n.t("admin.actions.test_ldap_server.error", error: e.message)
23
- end
24
- # Redirect to the object
25
- redirect_to index_path(model_name: @abstract_model.to_param)
26
- end
27
-
4
+ http_methods [:get, :post]
5
+
6
+ # Visible only for the User model
7
+ visible do
8
+ bindings[:object].is_a?(::LdapServer)
9
+ end
10
+ # Adding the controller which is needed to compute calls from the ui
11
+ controller do
12
+ proc do
13
+ # From the UI the user can test if the ldap server is reachable and receive a response
14
+ if request.get? || request.post?
15
+ @ldap = ::LdapServer.find(@object.id)
16
+ # begin
17
+ @ldap.test_connection
18
+ @status = "success"
19
+
20
+ @message = I18n.t("admin.actions.test_ldap_server.success")
21
+
22
+ # If in the form an email and password are provided, try to authenticate
23
+ if params[:email].present? && params[:password].present?
24
+ Rails.logger.debug("LDAP Test: Attempting to authenticate user #{params[:email]}")
25
+ authenticator = Ldap::Authenticator.new(
26
+ email: params[:email],
27
+ password: params[:password],
28
+ )
29
+ @ldap_user = authenticator.auth_on_single_server(@ldap)
30
+ Rails.logger.debug("LDAP Test: Authentication result for user #{params[:email]}: #{@ldap_user.inspect}")
31
+ # If @ldap_user exists, authentication succeeded
32
+ if @ldap_user
33
+ @message += " " + I18n.t("admin.actions.test_ldap_server.auth_success", email: params[:email])
34
+ else
35
+ @message += " " + I18n.t("admin.actions.test_ldap_server.auth_failure", email: params[:email])
36
+ @status = "warning"
37
+ end
28
38
  end
39
+ # rescue => e
40
+ # @message = I18n.t("admin.actions.test_ldap_server.error", error: e.message)
41
+ # @status = "danger"
42
+ # end
43
+ # Redirect to the object
44
+ # redirect_to index_path(model_name: @abstract_model.to_param)
45
+ end
29
46
  end
47
+ end
30
48
  end
@@ -1,3 +1,3 @@
1
1
  module ThecoreUiRailsAdmin
2
- VERSION = "3.5.3".freeze
2
+ VERSION = "3.5.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_ui_rails_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.3
4
+ version: 3.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni