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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e25d04c3b840bf878381f5e3a3e6d18bdd7dc5d22f1f50f26c8e3853c8406ba
|
|
4
|
+
data.tar.gz: 700433ded03b3f772826542c0538cb208e6e6948c852838c97e74fcfa494d40d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9134ec81516e589c99927f777a95a93afb4e8536ebb4c819be6fa5c31bbbfe73c90a72918b9178d49c667396834c7f411f46d0dc8acd618ce0eba53fcb12f602
|
|
7
|
+
data.tar.gz: 4c49d4697527d85773c940f2e5560acc34200e7b8d7cea001bedfc085ca3d1b8a9f8bf9ece6f76c77840b42bf3f844a0ebdf7b325e487b2433a683ba60a71dfe
|
|
@@ -1,10 +1,59 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|