Changeset 3670364
- Timestamp:
- 08/28/2026 12:46:46 PM (2 months ago)
- Location:
- sanch-multidomain-ldap-auth/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
sanch-multidomain-ldap-auth.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sanch-multidomain-ldap-auth/trunk/readme.txt
r3667184 r3670364 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.1. 87 Stable tag: 1.1.9 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 25 25 == Frequently Asked Questions == 26 26 27 = Does this plugin require the PHP LDAP extension? = 28 Yes, your web server must have the `php-ldap` PHP module enabled to initiate connections with your Active Directory Domain Controllers. 29 27 30 = How does the Intranet Blacklist mode work? = 28 31 First, all guests must log in. By default, all pages, categories, and posts are accessible to logged-in users. When you add a URL path or category to the plugin settings and map it to an AD Group, that path becomes restricted. Only users belonging to the mapped AD group will be able to view or edit it. If a category is restricted, all posts inside it inherit this restriction automatically. … … 30 33 == Changelog == 31 34 35 = 1.1.9 = 36 * Feature: Added visual Drag/Move (Up/Down) buttons to the mapping table to easily prioritize roles (Top-to-Bottom processing). 37 * UI/UX: Clarified the instructions for URL Protection, explaining that empty URL fields are valid for Role-only assignment. 38 32 39 = 1.1.8 = 33 * Feature: Implemented Strict Cascading ACL logic. Restricting access to a Category URL now automatically denies access to all posts belonging to that category across the frontend, REST API, and admin list tables , regardless of the post's individual permalink structure.34 * Performance: Optimized cascading checks by executing a direct bulk SQL query against `$wpdb->term_relationships` during transient generation , bypassing slow sequential `get_the_terms` lookups.40 * Feature: Implemented Strict Cascading ACL logic. Restricting access to a Category URL now automatically denies access to all posts belonging to that category across the frontend, REST API, and admin list tables. 41 * Performance: Optimized cascading checks by executing a direct bulk SQL query against `$wpdb->term_relationships` during transient generation. 35 42 36 43 = 1.1.7 = 37 44 * Critical Bugfix: Resolved an infinite recursion loop (PHP Fatal Error: Allowed memory size exhausted) triggered by `get_terms` executing within its own cache generation filter. Added strict DB cycle guards to prevent infinite loops in malformed page trees. 38 45 * Critical Bugfix: Prevented a fatal crash during AD user login by migrating from class-dependent `WP_Application_Passwords::delete_all_application_passwords()` to safe, direct core meta deletion `delete_user_meta()`. 39 * Feature: Overhauled the UI settings to use multi-line Textareas for URL mapping inputs , allowing administrators to visually list and manage restricted routes column by column.46 * Feature: Overhauled the UI settings to use multi-line Textareas for URL mapping inputs. 40 47 41 48 = 1.1.4 = -
sanch-multidomain-ldap-auth/trunk/sanch-multidomain-ldap-auth.php
r3667184 r3670364 3 3 * Plugin Name: Sanch MultiDomain LDAP Auth for Active Directory 4 4 * Description: Enterprise AD Integration: Mandatory Intranet Login, Blacklist ACL, Smart Tree Routing, and LDAP Guard. 5 * Version: 1.1. 85 * Version: 1.1.9 6 6 * Author: sanchshevchuk 7 7 * License: GPL v2 or later … … 468 468 } 469 469 470 // FIX 1.1.8: Strict Cascading Helper. Забороняє пост, якщо заборонена будь-яка з його категорій/міток471 470 function ad_auth_user_can_access_post($post_id) { 472 471 static $cache = []; … … 486 485 $t_link = get_term_link($term); 487 486 if (!is_wp_error($t_link) && !ad_auth_user_can_access_url($t_link)) { 488 return ($cache[$post_id] = false); // Якщо категорія заборонена -> пост заборонено!487 return ($cache[$post_id] = false); 489 488 } 490 489 } … … 547 546 if (isset($post->post_author) && $post->post_author == get_current_user_id()) return $response; 548 547 549 // FIX 1.1.8: Use the new strict cascade helper for REST API responses550 548 if (!ad_auth_user_can_access_post($post->ID)) { 551 549 return new WP_Error('rest_forbidden_acl', __('403 Forbidden: Content restricted.', 'sanch-multidomain-ldap-auth'), ['status' => 403]); … … 572 570 if ($post->post_author == $user_id) return $caps; 573 571 574 // FIX 1.1.8: User cannot edit a post if its category is restricted575 572 if (!ad_auth_user_can_access_post($post->ID)) { 576 573 $caps[] = 'do_not_allow'; … … 630 627 631 628 foreach ($pages as $page) { 632 // FIX 1.1.8: Check page cascade too633 629 if (ad_auth_user_can_access_post($page->ID)) { 634 630 $allowed_page_ids[$page->ID] = true; … … 785 781 )); 786 782 787 // FIX 1.1.8: Швидка перевірка заборонених категорій через SQL788 783 $restricted_term_ids = []; 789 784 remove_filter('get_terms', 'ad_auth_filter_terms', 10); … … 804 799 if (!empty($restricted_term_ids)) { 805 800 $term_ids_sql = implode(',', array_map('intval', $restricted_term_ids)); 806 // Дістаємо всі пости, що належать до заборонених категорій807 801 $restricted_posts_from_terms = $wpdb->get_col(" 808 802 SELECT tr.object_id … … 824 818 if (empty($p->post_name) && !in_array($p->post_status, ['publish', 'private'])) continue; 825 819 826 // Забороняємо, якщо URL поста заборонений АБО якщо пост лежить у забороненій категорії827 820 if (in_array($p->ID, $restricted_posts_from_terms) || !ad_auth_user_can_access_url(get_permalink($p->ID))) { 828 821 $strict_deny[] = $p->ID; … … 915 908 } else { 916 909 alert(strWarn); 910 } 911 } 912 if (e.target && e.target.classList.contains('move-up')) { 913 var row = e.target.closest('tr'); 914 if (row.previousElementSibling) { 915 row.parentNode.insertBefore(row, row.previousElementSibling); 916 } 917 } 918 if (e.target && e.target.classList.contains('move-down')) { 919 var row = e.target.closest('tr'); 920 if (row.nextElementSibling) { 921 row.parentNode.insertBefore(row.nextElementSibling, row); 917 922 } 918 923 } … … 1208 1213 </div> 1209 1214 <div class="inside"> 1210 <p style="margin-top: 0; font-size: 14px;">1211 <?php esc_html_e('MANDATORY LOGIN: All users must log in to access the site. Once logged in, all unmapped URLs are accessible. Map specific URLs to AD groups to RESTRICT those paths only to members of those groups.', 'sanch-multidomain-ldap-auth'); ?>1212 </p>1213 1215 1216 <!-- FIX 1.1.9: Оновлений блок підказки з чітким описом роботи правил --> 1214 1217 <div class="ad-tip-box"> 1215 <strong>💡 <?php esc_html_e(' Tip - Role vs Base:', 'sanch-multidomain-ldap-auth'); ?></strong><br>1216 <b> <?php esc_html_e('WP Role Code', 'sanch-multidomain-ldap-auth'); ?></b> <?php esc_html_e('is the unique ID for your group (e.g., department_reader, branch_editor) used to separate access.', 'sanch-multidomain-ldap-auth'); ?><br>1217 <b> <?php esc_html_e('Base Role', 'sanch-multidomain-ldap-auth'); ?></b> <?php esc_html_e('grants the actual physical permissions in WordPress (e.g., selecting Editor allows them to write posts).', 'sanch-multidomain-ldap-auth'); ?>1218 <strong>💡 <?php esc_html_e('How Mapping Works:', 'sanch-multidomain-ldap-auth'); ?></strong><br> 1219 <b>1. <?php esc_html_e('Role Priority (Top to Bottom):', 'sanch-multidomain-ldap-auth'); ?></b> <?php esc_html_e('A user gets the WP Role from the FIRST group they match from top to bottom. Use ↑/↓ buttons to prioritize Admins over Subscribers.', 'sanch-multidomain-ldap-auth'); ?><br> 1220 <b>2. <?php esc_html_e('URL Protection (Blacklist):', 'sanch-multidomain-ldap-auth'); ?></b> <?php esc_html_e('If you enter paths (like /?cat=6), they become LOCKED and visible ONLY to this AD Group. If left empty, this rule just assigns a role.', 'sanch-multidomain-ldap-auth'); ?> 1218 1221 </div> 1219 1222 … … 1224 1227 <th style="width: 20%;"><?php esc_html_e('WP Role Code (ID / Slug)', 'sanch-multidomain-ldap-auth'); ?></th> 1225 1228 <th style="width: 15%;"><?php esc_html_e('Capabilities (Base)', 'sanch-multidomain-ldap-auth'); ?></th> 1226 <th style="width: 35%;"><?php esc_html_e('Restricted URL Paths (One per line)', 'sanch-multidomain-ldap-auth'); ?></th> 1229 <!-- FIX 1.1.9: Нова назва колонки для кращого розуміння --> 1230 <th style="width: 35%;"><?php esc_html_e('🔒 Protect URLs (Only this group can access)', 'sanch-multidomain-ldap-auth'); ?> <br><small style="font-weight:normal; color:#666;">(One per line. Leave empty for role-only mapping)</small></th> 1227 1231 <th style="width: 10%; text-align: center;"><?php esc_html_e('Action', 'sanch-multidomain-ldap-auth'); ?></th> 1228 1232 </tr> … … 1267 1271 </select> 1268 1272 </td> 1269 <td style="text-align: center;"><button type="button" class="button remove-row"><?php esc_html_e('Remove', 'sanch-multidomain-ldap-auth'); ?></button></td> 1273 <!-- FIX 1.1.9: Додано кнопки сортування ↑ ↓ --> 1274 <td style="text-align: center; vertical-align: middle;"> 1275 <div style="display: flex; gap: 4px; justify-content: center; margin-bottom: 4px;"> 1276 <button type="button" class="button move-up" title="Move Up">↑</button> 1277 <button type="button" class="button move-down" title="Move Down">↓</button> 1278 </div> 1279 <button type="button" class="button remove-row" style="width: 100%; text-align: center;"><?php esc_html_e('Remove', 'sanch-multidomain-ldap-auth'); ?></button> 1280 </td> 1270 1281 </tr> 1271 1282 <?php endforeach; ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)