thecore_ui_rails_admin 3.5.3 → 3.5.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 +4 -4
- data/app/views/rails_admin/main/test_ldap_server.html.erb +66 -8
- data/app/views/rails_admin/main/test_ldap_server.js.erb +19 -0
- data/config/initializers/after_initialize.rb +54 -54
- data/lib/member_actions/test_ldap_server.rb +56 -26
- data/lib/thecore_ui_rails_admin/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee26f7626aa5d9fe655b1b9adf800507d5ff7628985926577ed12741a9c9243d
|
|
4
|
+
data.tar.gz: b17ec42cddf7f44951c0234d1d445c968a5d9f35116f4d4c84f5ac4682fe75e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7bbce89f9c60dccff3a1fc235166fdbcc2c7d9817336d0982d280b807231f2ae64bc80ae918f6789b1c91e1716296047de6d2c8a20631223ade6578f81b1cae8
|
|
7
|
+
data.tar.gz: ef4f4b943bbf0437dc89852df5ee0c49db52181242bdd78a3e22983a05bccf894d3c4a5dfe062960ca303eb865f3524211921fdee8c2e9b3c37addc09d87361e
|
|
@@ -1,10 +1,68 @@
|
|
|
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, remote: true, local: false 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', id: "test-connection" %>
|
|
38
|
+
<% end %>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<!-- In the @ldap_user variable, if present, show the details of the authenticated user, I'll fill these via JS -->
|
|
43
|
+
<div class="card mt-4 visually-hidden" id="ldap-user-details">
|
|
44
|
+
<div class="card-header">
|
|
45
|
+
<h5>Authenticated LDAP User Details</h5>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="card-body">
|
|
48
|
+
<p><strong>DN:</strong> <span id="ldap-user-dn"></span></p>
|
|
49
|
+
<p><strong>Attributes:</strong></p>
|
|
50
|
+
<ul id="ldap-user-attributes">
|
|
51
|
+
</ul>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<span id="spinner" class="spinner-grow spinner-grow-sm visually-hidden" role="status" aria-hidden="true"></span>
|
|
56
|
+
|
|
57
|
+
<script>
|
|
58
|
+
// This is the javascript that will update the div with the new token //-->
|
|
59
|
+
document.addEventListener("turbo:load", function() {
|
|
60
|
+
$('#test-connection').on('click', function(e, data, status, xhr) {
|
|
61
|
+
$('#spinner').removeClass("visually-hidden");
|
|
62
|
+
// Clear the previous user details
|
|
63
|
+
$("#ldap-user-dn").text("");
|
|
64
|
+
$("#ldap-user-attributes").empty();
|
|
65
|
+
$("#ldap-user-details").addClass("visually-hidden");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
$('#spinner').addClass("visually-hidden");
|
|
2
|
+
|
|
3
|
+
console.log("LDAP Test: Received response from server.");
|
|
4
|
+
|
|
5
|
+
// If @ldap_user exists, authentication succeeded, translate the following Ruby code to jQuery
|
|
6
|
+
<% if @ldap_user %>
|
|
7
|
+
<% @ldap_attributes.each do |key, values| %>
|
|
8
|
+
$("#ldap-user-attributes").append("<li><strong><%= j key %>:</strong> <%= j values.join(', ') %></li>");
|
|
9
|
+
<% end %>
|
|
10
|
+
|
|
11
|
+
// Remove the visually-hidden class to show the user details section from the #ldap-user-details div
|
|
12
|
+
$("#ldap-user-details").removeClass("visually-hidden");
|
|
13
|
+
|
|
14
|
+
// Set the DN span text to the user's DN
|
|
15
|
+
$("#ldap-user-dn").text("<%= j @ldap_user.dn %>");
|
|
16
|
+
<% else %>
|
|
17
|
+
// If no @ldap_user, hide the user details section
|
|
18
|
+
$("#ldap-user-details").addClass("visually-hidden");
|
|
19
|
+
<% end %>
|
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
Rails.application.configure do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
RailsAdmin::Config.current_user_method(&:current_user)
|
|
17
|
-
|
|
18
|
-
## == Cancan ==
|
|
19
|
-
RailsAdmin::Config.authorize_with :cancancan
|
|
20
|
-
|
|
21
|
-
RailsAdmin::Config.main_app_name = Proc.new { |controller| [ ((ThecoreSettings::Setting.where(ns: :main, key: :app_name).pluck(:raw).first.presence || ENV["APP_NAME"]) rescue "Thecore"), "" ] }
|
|
22
|
-
|
|
23
|
-
RailsAdmin::Config.show_gravatar = false
|
|
24
|
-
|
|
25
|
-
RailsAdmin::Config.label_methods.unshift(:display_name)
|
|
26
|
-
|
|
27
|
-
RailsAdmin::Config.excluded_models << ActionText::RichText
|
|
28
|
-
RailsAdmin::Config.excluded_models << ActionText::EncryptedRichText
|
|
29
|
-
RailsAdmin::Config.excluded_models << ActiveStorage::Blob
|
|
30
|
-
RailsAdmin::Config.excluded_models << ActiveStorage::Attachment
|
|
31
|
-
RailsAdmin::Config.excluded_models << ActiveStorage::VariantRecord
|
|
32
|
-
RailsAdmin::Config.excluded_models << ActionMailbox::InboundEmail
|
|
33
|
-
RailsAdmin::Config.excluded_models << UsedToken rescue puts "No UsedToken Model it could be normal: maybe model_driven_api is not installed"
|
|
34
|
-
|
|
35
|
-
RailsAdmin::Config::Actions::Export.send(:include, ExportConcern)
|
|
36
|
-
RailsAdmin::Config::Actions::BulkDelete.send(:include, BulkDeleteConcern)
|
|
37
|
-
|
|
38
|
-
Role.send :include, ThecoreUiRailsAdminRoleConcern
|
|
39
|
-
User.send :include, ThecoreUiRailsAdminUserConcern
|
|
40
|
-
RoleUser.send :include, ThecoreUiRailsAdminRoleUserConcern
|
|
41
|
-
Action.send :include, ThecoreUiRailsAdminActionConcern
|
|
42
|
-
PermissionRole.send :include, ThecoreUiRailsAdminPermissionRoleConcern
|
|
43
|
-
Permission.send :include, ThecoreUiRailsAdminPermissionConcern
|
|
44
|
-
Predicate.send :include, ThecoreUiRailsAdminPredicateConcern
|
|
45
|
-
Target.send :include, ThecoreUiRailsAdminTargetConcern
|
|
46
|
-
ThecoreSettings::Setting.send :include, ThecoreUiRailsAdminSettingsConcern
|
|
47
|
-
|
|
48
|
-
require 'root_actions/general_computation'
|
|
49
|
-
require 'root_actions/active_job_monitor'
|
|
50
|
-
require 'member_actions/change_password'
|
|
51
|
-
require 'member_actions/test_ldap_server'
|
|
52
|
-
require 'member_actions/import_users_from_ldap'
|
|
53
|
-
require 'collection_actions/save_filters'
|
|
54
|
-
require 'collection_actions/load_filters'
|
|
2
|
+
config.after_initialize do
|
|
3
|
+
puts "ThecoreUiRailsAdmin after_initialize"
|
|
4
|
+
|
|
5
|
+
RailsAdmin::ApplicationController.send(:include, ConcernCommonApplicationController)
|
|
6
|
+
ApplicationController.send(:include, ConcernRAApplicationController)
|
|
7
|
+
RailsAdmin::ApplicationController.send(:include, ConcernRAApplicationController)
|
|
8
|
+
## Rails Admin
|
|
9
|
+
require "rails_admin_abstract_controller"
|
|
10
|
+
RailsAdmin::Config.parent_controller = "::RailsAdminAbstractController"
|
|
11
|
+
### More at https://github.com/sferik/rails_admin/wiki/Base-configuration
|
|
12
|
+
## == Devise ==
|
|
13
|
+
RailsAdmin::Config.authenticate_with do
|
|
14
|
+
warden.authenticate! scope: :user
|
|
55
15
|
end
|
|
56
|
-
|
|
16
|
+
RailsAdmin::Config.current_user_method(&:current_user)
|
|
17
|
+
|
|
18
|
+
## == Cancan ==
|
|
19
|
+
RailsAdmin::Config.authorize_with :cancancan
|
|
20
|
+
|
|
21
|
+
RailsAdmin::Config.main_app_name = Proc.new { |controller| [((ThecoreSettings::Setting.where(ns: :main, key: :app_name).pluck(:raw).first.presence || ENV["APP_NAME"]) rescue "Thecore"), ""] }
|
|
22
|
+
|
|
23
|
+
RailsAdmin::Config.show_gravatar = false
|
|
24
|
+
|
|
25
|
+
RailsAdmin::Config.label_methods.unshift(:display_name)
|
|
26
|
+
|
|
27
|
+
RailsAdmin::Config.excluded_models << ActionText::RichText
|
|
28
|
+
RailsAdmin::Config.excluded_models << ActionText::EncryptedRichText
|
|
29
|
+
RailsAdmin::Config.excluded_models << ActiveStorage::Blob
|
|
30
|
+
RailsAdmin::Config.excluded_models << ActiveStorage::Attachment
|
|
31
|
+
RailsAdmin::Config.excluded_models << ActiveStorage::VariantRecord
|
|
32
|
+
RailsAdmin::Config.excluded_models << ActionMailbox::InboundEmail
|
|
33
|
+
RailsAdmin::Config.excluded_models << UsedToken rescue puts "No UsedToken Model it could be normal: maybe model_driven_api is not installed"
|
|
34
|
+
|
|
35
|
+
RailsAdmin::Config::Actions::Export.send(:include, ExportConcern)
|
|
36
|
+
RailsAdmin::Config::Actions::BulkDelete.send(:include, BulkDeleteConcern)
|
|
37
|
+
|
|
38
|
+
Role.send :include, ThecoreUiRailsAdminRoleConcern
|
|
39
|
+
User.send :include, ThecoreUiRailsAdminUserConcern
|
|
40
|
+
RoleUser.send :include, ThecoreUiRailsAdminRoleUserConcern
|
|
41
|
+
Action.send :include, ThecoreUiRailsAdminActionConcern
|
|
42
|
+
PermissionRole.send :include, ThecoreUiRailsAdminPermissionRoleConcern
|
|
43
|
+
Permission.send :include, ThecoreUiRailsAdminPermissionConcern
|
|
44
|
+
Predicate.send :include, ThecoreUiRailsAdminPredicateConcern
|
|
45
|
+
Target.send :include, ThecoreUiRailsAdminTargetConcern
|
|
46
|
+
ThecoreSettings::Setting.send :include, ThecoreUiRailsAdminSettingsConcern
|
|
47
|
+
|
|
48
|
+
require "root_actions/general_computation"
|
|
49
|
+
require "root_actions/active_job_monitor"
|
|
50
|
+
require "member_actions/change_password"
|
|
51
|
+
require "member_actions/test_ldap_server"
|
|
52
|
+
# require 'member_actions/import_users_from_ldap' # Disabled as it's a bit risky to have it in the UI
|
|
53
|
+
require "collection_actions/save_filters"
|
|
54
|
+
require "collection_actions/load_filters"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -1,30 +1,60 @@
|
|
|
1
1
|
RailsAdmin::Config::Actions.add_action "test_ldap_server", :base, :member do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
link_icon "fas fa-circle-check"
|
|
3
|
+
|
|
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
|
+
@ldap = ::LdapServer.find(@object.id)
|
|
14
|
+
# begin
|
|
15
|
+
@ldap.test_connection
|
|
16
|
+
@status = "success"
|
|
17
|
+
|
|
18
|
+
@message = I18n.t("admin.actions.test_ldap_server.success")
|
|
19
|
+
|
|
20
|
+
# From the UI the user can test if the ldap server is reachable and receive a response
|
|
21
|
+
if request.xhr? && request.post? && params[:email].present? && params[:password].present?
|
|
22
|
+
Rails.logger.debug("LDAP Test: Attempting to authenticate user #{params[:email]}")
|
|
23
|
+
authenticator = Ldap::Authenticator.new(
|
|
24
|
+
email: params[:email],
|
|
25
|
+
password: params[:password],
|
|
26
|
+
)
|
|
27
|
+
@ldap_user = authenticator.auth_on_single_server(@ldap)
|
|
28
|
+
@ldap_attributes = {}
|
|
29
|
+
|
|
30
|
+
@ldap_user.each_attribute do |key, values|
|
|
31
|
+
safe_values = values.map do |v|
|
|
32
|
+
s = v.to_s
|
|
33
|
+
|
|
34
|
+
# 1. Declare UTF-8
|
|
35
|
+
s.force_encoding("UTF-8")
|
|
36
|
+
|
|
37
|
+
# 2. Replace invalid / undefined bytes
|
|
38
|
+
s.encode!("UTF-8", invalid: :replace, undef: :replace, replace: "�")
|
|
39
|
+
|
|
40
|
+
s
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
@ldap_attributes[key] = safe_values
|
|
44
|
+
end
|
|
45
|
+
Rails.logger.debug("LDAP Test: Authentication result for user #{params[:email]}: #{@ldap_user.inspect}")
|
|
46
|
+
if @ldap_user
|
|
47
|
+
@message += " " + I18n.t("admin.actions.test_ldap_server.auth_success", email: params[:email])
|
|
48
|
+
else
|
|
49
|
+
@message += " " + I18n.t("admin.actions.test_ldap_server.auth_failure", email: params[:email])
|
|
50
|
+
@status = "warning"
|
|
28
51
|
end
|
|
52
|
+
# else
|
|
53
|
+
# rescue => e
|
|
54
|
+
# @message = I18n.t("admin.actions.test_ldap_server.error", error: e.message)
|
|
55
|
+
# @status = "danger"
|
|
56
|
+
# end
|
|
57
|
+
end
|
|
29
58
|
end
|
|
59
|
+
end
|
|
30
60
|
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.
|
|
4
|
+
version: 3.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriele Tassoni
|
|
@@ -94,6 +94,7 @@ files:
|
|
|
94
94
|
- app/views/rails_admin/main/load_filters.html.erb
|
|
95
95
|
- app/views/rails_admin/main/save_filter.html.erb
|
|
96
96
|
- app/views/rails_admin/main/test_ldap_server.html.erb
|
|
97
|
+
- app/views/rails_admin/main/test_ldap_server.js.erb
|
|
97
98
|
- config/initializers/abilities.rb
|
|
98
99
|
- config/initializers/add_to_db_migrations.rb
|
|
99
100
|
- config/initializers/after_initialize.rb
|