thecore_ui_rails_admin 3.5.4 → 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 +28 -19
- 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 +37 -25
- 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
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<h5>Test LDAP Connection with Custom Credentials</h5>
|
|
26
26
|
</div>
|
|
27
27
|
<div class="card-body">
|
|
28
|
-
<%= form_with url: rails_admin.test_ldap_server_path, method: :post,
|
|
28
|
+
<%= form_with url: rails_admin.test_ldap_server_path, method: :post, remote: true, local: false do |form| %>
|
|
29
29
|
<div class="mb-3">
|
|
30
30
|
<%= form.label :email, 'Email', class: 'form-label' %>
|
|
31
31
|
<%= form.email_field :email, class: 'form-control', required: true %>
|
|
@@ -34,26 +34,35 @@
|
|
|
34
34
|
<%= form.label :password, 'Password', class: 'form-label' %>
|
|
35
35
|
<%= form.password_field :password, class: 'form-control', required: true %>
|
|
36
36
|
</div>
|
|
37
|
-
<%= form.submit 'Test Connection', class: 'btn btn-primary' %>
|
|
37
|
+
<%= form.submit 'Test Connection', class: 'btn btn-primary', id: "test-connection" %>
|
|
38
38
|
<% end %>
|
|
39
39
|
</div>
|
|
40
40
|
</div>
|
|
41
41
|
|
|
42
|
-
<!-- In the @ldap_user variable, if present, show the details of the authenticated user -->
|
|
43
|
-
|
|
44
|
-
<div class="card
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<% @ldap_user.each_attribute do |key, values| %>
|
|
53
|
-
<li><strong><%= key %>:</strong> <%= values.join(', ') %></li>
|
|
54
|
-
<% end %>
|
|
55
|
-
</ul>
|
|
56
|
-
|
|
57
|
-
</div>
|
|
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>
|
|
58
52
|
</div>
|
|
59
|
-
|
|
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
|
|
@@ -10,38 +10,50 @@ RailsAdmin::Config::Actions.add_action "test_ldap_server", :base, :member do
|
|
|
10
10
|
# Adding the controller which is needed to compute calls from the ui
|
|
11
11
|
controller do
|
|
12
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
|
+
|
|
13
20
|
# From the UI the user can test if the ldap server is reachable and receive a response
|
|
14
|
-
if request.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
else
|
|
35
|
-
@message += " " + I18n.t("admin.actions.test_ldap_server.auth_failure", email: params[:email])
|
|
36
|
-
@status = "warning"
|
|
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
|
|
37
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"
|
|
38
51
|
end
|
|
52
|
+
# else
|
|
39
53
|
# rescue => e
|
|
40
54
|
# @message = I18n.t("admin.actions.test_ldap_server.error", error: e.message)
|
|
41
55
|
# @status = "danger"
|
|
42
56
|
# end
|
|
43
|
-
# Redirect to the object
|
|
44
|
-
# redirect_to index_path(model_name: @abstract_model.to_param)
|
|
45
57
|
end
|
|
46
58
|
end
|
|
47
59
|
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
|