PluginProbe
Authorizer / 3.6.0
Authorizer v3.6.0
3.16.0 3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 All 127 releases
← All changes | src/authorizer/class-options.php +172 -39 2.9.13.6.0 View file →
@@ -13,9 +13,9 @@
13 13
14 14 /**
15 15 * Contains functions for rendering the Access Lists tab in Authorizer Settings.
16 16 */
17 -class Options extends Static_Instance {
17 +class Options extends Singleton {
18 18
19 19 /**
20 20 * Retrieves a specific plugin option from db. Multisite enabled.
21 21 *
@@ -37,8 +37,11 @@
37 37
38 38 // Get all plugin options.
39 39 $auth_settings = $this->get_all( $admin_mode, $override_mode );
40 40
41 + // Get multisite options (for checking if multisite override is prevented).
42 + $auth_multisite_settings = is_multisite() ? get_blog_option( get_network()->blog_id, 'auth_multisite_settings', array() ) : array();
43 +
41 44 // Set option to null if it wasn't found.
42 45 if ( ! array_key_exists( $option, $auth_settings ) ) {
43 46 return null;
44 47 }
@@ -50,9 +53,13 @@
50 53 'allow override' === $override_mode &&
51 54 'print overlay' === $print_mode &&
52 55 array_key_exists( 'multisite_override', $auth_settings ) &&
53 56 '1' === $auth_settings['multisite_override'] &&
54 - ( ! array_key_exists( 'advanced_override_multisite', $auth_settings ) || 1 !== intval( $auth_settings['advanced_override_multisite'] ) )
57 + (
58 + ! array_key_exists( 'advanced_override_multisite', $auth_settings ) ||
59 + 1 !== intval( $auth_settings['advanced_override_multisite'] ) ||
60 + ! empty( $auth_multisite_settings['prevent_override_multisite'] )
61 + )
55 62 ) {
56 63 // Get original plugin options (not overridden value). We'll
57 64 // show this old value behind the disabled overlay.
58 65 // $auth_settings = $this->get_all( $admin_mode, 'no override' );
@@ -59,20 +66,35 @@
59 66 // (This feature is disabled).
60 67 //
61 68 $name = "auth_settings[$option]";
62 69 $id = "auth_settings_$option";
70 + // Get category of option so we can link directly to the appropriate tab
71 + // in multisite options (most options are on the External Service tab;
72 + // only access_who_can_login and access_who_can_view are on the Access
73 + // Lists tab; all options on the Advanced tab start with "advanced_").
74 + $tab = '&tab=external';
75 + if ( 'access_who_can_login' === $option || 'access_who_can_view' === $option ) {
76 + $tab = '&tab=access_lists';
77 + } elseif ( 0 === strpos( $option, 'advanced_' ) ) {
78 + $tab = '&tab=advanced';
79 + }
63 80 ?>
64 81 <div id="overlay-hide-auth_settings_<?php echo esc_attr( $option ); ?>" class="auth_multisite_override_overlay">
65 82 <span class="overlay-note">
66 - <?php esc_html_e( 'This setting is overridden by a', 'authorizer' ); ?> <a href="<?php echo esc_attr( network_admin_url( 'admin.php?page=authorizer' ) ); ?>"><?php esc_html_e( 'multisite option', 'authorizer' ); ?></a>.
83 + <?php esc_html_e( 'This setting is overridden by a', 'authorizer' ); ?> <a href="<?php echo esc_attr( network_admin_url( 'admin.php?page=authorizer' . $tab ) ); ?>"><?php esc_html_e( 'multisite option', 'authorizer' ); ?></a>.
67 84 </span>
68 85 </div>
69 86 <?php
70 87 }
71 88
72 - // If we're getting an option in a site that has overridden the multisite override, make
73 - // sure we are returning the option value from that site (not the multisite value).
74 - if ( array_key_exists( 'advanced_override_multisite', $auth_settings ) && 1 === intval( $auth_settings['advanced_override_multisite'] ) ) {
89 + // If we're getting an option in a site that has overridden the multisite
90 + // override (and is not prevented from doing so), make sure we are returning
91 + // the option value from that site (not the multisite value).
92 + if (
93 + array_key_exists( 'advanced_override_multisite', $auth_settings ) &&
94 + 1 === intval( $auth_settings['advanced_override_multisite'] ) &&
95 + empty( $auth_multisite_settings['prevent_override_multisite'] )
96 + ) {
75 97 $auth_settings = $this->get_all( $admin_mode, 'no override' );
76 98 }
77 99
78 100 // Set option to null if it wasn't found.
@@ -98,10 +120,10 @@
98 120 if ( false === $auth_settings ) {
99 121 $auth_settings = $this->set_default_options();
100 122 }
101 123
102 - // Merge multisite options if we're in a network and the current site hasn't overridden multisite settings.
103 - if ( is_multisite() && ( ! array_key_exists( 'advanced_override_multisite', $auth_settings ) || 1 !== intval( $auth_settings['advanced_override_multisite'] ) ) ) {
124 + // Merge multisite options if we're in a network.
125 + if ( is_multisite() ) {
104 126 // Get multisite options.
105 127 $auth_multisite_settings = get_blog_option( get_network()->blog_id, 'auth_multisite_settings', array() );
106 128
107 129 // Return the multisite options if we're viewing the network admin options page.
@@ -112,11 +134,22 @@
112 134 'allow override' === $override_mode &&
113 135 array_key_exists( 'multisite_override', $auth_multisite_settings ) &&
114 136 '1' === $auth_multisite_settings['multisite_override']
115 137 ) {
116 - // Keep track of the multisite override selection.
117 - $auth_settings['multisite_override'] = $auth_multisite_settings['multisite_override'];
138 + // Keep track of the multisite override (and prevention) selection.
139 + $auth_settings['multisite_override'] = $auth_multisite_settings['multisite_override'];
140 + $auth_settings['prevent_override_multisite'] = $auth_multisite_settings['prevent_override_multisite'];
118 141
142 + // Don't merge multisite options if the current site has overridden them
143 + // (and isn't prevented from doing so).
144 + if (
145 + array_key_exists( 'advanced_override_multisite', $auth_settings ) &&
146 + 1 === intval( $auth_settings['advanced_override_multisite'] ) &&
147 + empty( $auth_settings['prevent_override_multisite'] )
148 + ) {
149 + return $auth_settings;
150 + }
151 +
119 152 /**
120 153 * Note: the options below should be the complete list of overridden
121 154 * options. It is *not* the complete list of all options (some options
122 155 * don't have a multisite equivalent).
@@ -133,8 +166,18 @@
133 166 * $ms_approved_users = $options->get( 'access_users_approved', Helper::NETWORK_CONTEXT );
134 167 */
135 168
136 169 // Override external services (google, cas, or ldap) and associated options.
170 + $auth_settings['oauth2'] = $auth_multisite_settings['oauth2'];
171 + $auth_settings['oauth2_provider'] = $auth_multisite_settings['oauth2_provider'];
172 + $auth_settings['oauth2_custom_label'] = $auth_multisite_settings['oauth2_custom_label'];
173 + $auth_settings['oauth2_clientid'] = $auth_multisite_settings['oauth2_clientid'];
174 + $auth_settings['oauth2_clientsecret'] = $auth_multisite_settings['oauth2_clientsecret'];
175 + $auth_settings['oauth2_hosteddomain'] = $auth_multisite_settings['oauth2_hosteddomain'];
176 + $auth_settings['oauth2_tenant_id'] = $auth_multisite_settings['oauth2_tenant_id'];
177 + $auth_settings['oauth2_url_authorize'] = $auth_multisite_settings['oauth2_url_authorize'];
178 + $auth_settings['oauth2_url_token'] = $auth_multisite_settings['oauth2_url_token'];
179 + $auth_settings['oauth2_url_resource'] = $auth_multisite_settings['oauth2_url_resource'];
137 180 $auth_settings['google'] = $auth_multisite_settings['google'];
138 181 $auth_settings['google_clientid'] = $auth_multisite_settings['google_clientid'];
139 182 $auth_settings['google_clientsecret'] = $auth_multisite_settings['google_clientsecret'];
140 183 $auth_settings['google_hosteddomain'] = $auth_multisite_settings['google_hosteddomain'];
@@ -142,8 +185,9 @@
142 185 $auth_settings['cas_custom_label'] = $auth_multisite_settings['cas_custom_label'];
143 186 $auth_settings['cas_host'] = $auth_multisite_settings['cas_host'];
144 187 $auth_settings['cas_port'] = $auth_multisite_settings['cas_port'];
145 188 $auth_settings['cas_path'] = $auth_multisite_settings['cas_path'];
189 + $auth_settings['cas_method'] = $auth_multisite_settings['cas_method'];
146 190 $auth_settings['cas_version'] = $auth_multisite_settings['cas_version'];
147 191 $auth_settings['cas_attr_email'] = $auth_multisite_settings['cas_attr_email'];
148 192 $auth_settings['cas_attr_first_name'] = $auth_multisite_settings['cas_attr_first_name'];
149 193 $auth_settings['cas_attr_last_name'] = $auth_multisite_settings['cas_attr_last_name'];
@@ -154,8 +198,9 @@
154 198 $auth_settings['ldap_host'] = $auth_multisite_settings['ldap_host'];
155 199 $auth_settings['ldap_port'] = $auth_multisite_settings['ldap_port'];
156 200 $auth_settings['ldap_tls'] = $auth_multisite_settings['ldap_tls'];
157 201 $auth_settings['ldap_search_base'] = $auth_multisite_settings['ldap_search_base'];
202 + $auth_settings['ldap_search_filter'] = $auth_multisite_settings['ldap_search_filter'];
158 203 $auth_settings['ldap_uid'] = $auth_multisite_settings['ldap_uid'];
159 204 $auth_settings['ldap_attr_email'] = $auth_multisite_settings['ldap_attr_email'];
160 205 $auth_settings['ldap_user'] = $auth_multisite_settings['ldap_user'];
161 206 $auth_settings['ldap_password'] = $auth_multisite_settings['ldap_password'];
@@ -162,8 +207,9 @@
162 207 $auth_settings['ldap_lostpassword_url'] = $auth_multisite_settings['ldap_lostpassword_url'];
163 208 $auth_settings['ldap_attr_first_name'] = $auth_multisite_settings['ldap_attr_first_name'];
164 209 $auth_settings['ldap_attr_last_name'] = $auth_multisite_settings['ldap_attr_last_name'];
165 210 $auth_settings['ldap_attr_update_on_login'] = $auth_multisite_settings['ldap_attr_update_on_login'];
211 + $auth_settings['ldap_test_user'] = $auth_multisite_settings['ldap_test_user'];
166 212
167 213 // Override access_who_can_login and access_who_can_view.
168 214 $auth_settings['access_who_can_login'] = $auth_multisite_settings['access_who_can_login'];
169 215 $auth_settings['access_who_can_view'] = $auth_multisite_settings['access_who_can_view'];
@@ -176,8 +222,11 @@
176 222
177 223 // Override Hide WordPress login.
178 224 $auth_settings['advanced_hide_wp_login'] = $auth_multisite_settings['advanced_hide_wp_login'];
179 225
226 + // Override Disable WordPress login.
227 + $auth_settings['advanced_disable_wp_login'] = $auth_multisite_settings['advanced_disable_wp_login'];
228 +
180 229 // Override Users per page.
181 230 $auth_settings['advanced_users_per_page'] = $auth_multisite_settings['advanced_users_per_page'];
182 231
183 232 // Override Sort users by.
@@ -282,8 +331,11 @@
282 331 $auth_settings['access_default_role'] = 'subscriber';
283 332 }
284 333 }
285 334
335 + if ( ! array_key_exists( 'oauth2', $auth_settings ) ) {
336 + $auth_settings['oauth2'] = '';
337 + }
286 338 if ( ! array_key_exists( 'google', $auth_settings ) ) {
287 339 $auth_settings['google'] = '';
288 340 }
289 341 if ( ! array_key_exists( 'cas', $auth_settings ) ) {
@@ -302,8 +354,36 @@
302 354 if ( ! array_key_exists( 'google_hosteddomain', $auth_settings ) ) {
303 355 $auth_settings['google_hosteddomain'] = '';
304 356 }
305 357
358 + if ( ! array_key_exists( 'oauth2_provider', $auth_settings ) ) {
359 + $auth_settings['oauth2_provider'] = '';
360 + }
361 + if ( ! array_key_exists( 'oauth2_custom_label', $auth_settings ) ) {
362 + $auth_settings['oauth2_custom_label'] = 'OAuth2';
363 + }
364 + if ( ! array_key_exists( 'oauth2_clientid', $auth_settings ) ) {
365 + $auth_settings['oauth2_clientid'] = '';
366 + }
367 + if ( ! array_key_exists( 'oauth2_clientsecret', $auth_settings ) ) {
368 + $auth_settings['oauth2_clientsecret'] = '';
369 + }
370 + if ( ! array_key_exists( 'oauth2_hosteddomain', $auth_settings ) ) {
371 + $auth_settings['oauth2_hosteddomain'] = '';
372 + }
373 + if ( ! array_key_exists( 'oauth2_tenant_id', $auth_settings ) ) {
374 + $auth_settings['oauth2_tenant_id'] = 'common';
375 + }
376 + if ( ! array_key_exists( 'oauth2_url_authorize', $auth_settings ) ) {
377 + $auth_settings['oauth2_url_authorize'] = '';
378 + }
379 + if ( ! array_key_exists( 'oauth2_url_token', $auth_settings ) ) {
380 + $auth_settings['oauth2_url_token'] = '';
381 + }
382 + if ( ! array_key_exists( 'oauth2_url_resource', $auth_settings ) ) {
383 + $auth_settings['oauth2_url_resource'] = '';
384 + }
385 +
306 386 if ( ! array_key_exists( 'cas_custom_label', $auth_settings ) ) {
307 387 $auth_settings['cas_custom_label'] = 'CAS';
308 388 }
309 389 if ( ! array_key_exists( 'cas_host', $auth_settings ) ) {
@@ -314,10 +394,13 @@
314 394 }
315 395 if ( ! array_key_exists( 'cas_path', $auth_settings ) ) {
316 396 $auth_settings['cas_path'] = '';
317 397 }
398 + if ( ! array_key_exists( 'cas_method', $auth_settings ) ) {
399 + $auth_settings['cas_method'] = Options\External\Cas::get_instance()->sanitize_cas_method();
400 + }
318 401 if ( ! array_key_exists( 'cas_version', $auth_settings ) ) {
319 - $auth_settings['cas_version'] = 'SAML_VERSION_1_1';
402 + $auth_settings['cas_version'] = Options\External\Cas::get_instance()->sanitize_cas_version();
320 403 }
321 404 if ( ! array_key_exists( 'cas_attr_email', $auth_settings ) ) {
322 405 $auth_settings['cas_attr_email'] = '';
323 406 }
@@ -348,8 +431,11 @@
348 431 }
349 432 if ( ! array_key_exists( 'ldap_search_base', $auth_settings ) ) {
350 433 $auth_settings['ldap_search_base'] = '';
351 434 }
435 + if ( ! array_key_exists( 'ldap_search_filter', $auth_settings ) ) {
436 + $auth_settings['ldap_search_filter'] = '';
437 + }
352 438 if ( ! array_key_exists( 'ldap_uid', $auth_settings ) ) {
353 439 $auth_settings['ldap_uid'] = 'uid';
354 440 }
355 441 if ( ! array_key_exists( 'ldap_attr_email', $auth_settings ) ) {
@@ -372,8 +458,11 @@
372 458 }
373 459 if ( ! array_key_exists( 'ldap_attr_update_on_login', $auth_settings ) ) {
374 460 $auth_settings['ldap_attr_update_on_login'] = '';
375 461 }
462 + if ( ! array_key_exists( 'ldap_test_user', $auth_settings ) ) {
463 + $auth_settings['ldap_test_user'] = '';
464 + }
376 465
377 466 // Advanced defaults.
378 467 if ( ! array_key_exists( 'advanced_lockouts', $auth_settings ) ) {
379 468 $auth_settings['advanced_lockouts'] = array(
@@ -386,8 +475,11 @@
386 475 }
387 476 if ( ! array_key_exists( 'advanced_hide_wp_login', $auth_settings ) ) {
388 477 $auth_settings['advanced_hide_wp_login'] = '';
389 478 }
479 + if ( ! array_key_exists( 'advanced_disable_wp_login', $auth_settings ) ) {
480 + $auth_settings['advanced_disable_wp_login'] = '';
481 + }
390 482 if ( ! array_key_exists( 'advanced_branding', $auth_settings ) ) {
391 483 $auth_settings['advanced_branding'] = 'default';
392 484 }
393 485 if ( ! array_key_exists( 'advanced_admin_menu', $auth_settings ) ) {
@@ -428,8 +520,12 @@
428 520 // Global switch for enabling multisite options.
429 521 if ( ! array_key_exists( 'multisite_override', $auth_multisite_settings ) ) {
430 522 $auth_multisite_settings['multisite_override'] = '';
431 523 }
524 + // Global switch for preventing sites from overriding multisite options.
525 + if ( ! array_key_exists( 'prevent_override_multisite', $auth_multisite_settings ) ) {
526 + $auth_multisite_settings['prevent_override_multisite'] = '';
527 + }
432 528 // Access Lists Defaults.
433 529 $auth_multisite_settings_access_users_approved = get_blog_option( get_network()->blog_id, 'auth_multisite_settings_access_users_approved' );
434 530 if ( false === $auth_multisite_settings_access_users_approved ) {
435 531 $auth_multisite_settings_access_users_approved = array();
@@ -452,8 +548,11 @@
452 548 } else {
453 549 $auth_multisite_settings['access_default_role'] = 'subscriber';
454 550 }
455 551 }
552 + if ( ! array_key_exists( 'oauth2', $auth_multisite_settings ) ) {
553 + $auth_multisite_settings['oauth2'] = '';
554 + }
456 555 if ( ! array_key_exists( 'google', $auth_multisite_settings ) ) {
457 556 $auth_multisite_settings['google'] = '';
458 557 }
459 558 if ( ! array_key_exists( 'cas', $auth_multisite_settings ) ) {
@@ -461,8 +560,35 @@
461 560 }
462 561 if ( ! array_key_exists( 'ldap', $auth_multisite_settings ) ) {
463 562 $auth_multisite_settings['ldap'] = '';
464 563 }
564 + if ( ! array_key_exists( 'oauth2_provider', $auth_multisite_settings ) ) {
565 + $auth_multisite_settings['oauth2_provider'] = '';
566 + }
567 + if ( ! array_key_exists( 'oauth2_custom_label', $auth_multisite_settings ) ) {
568 + $auth_multisite_settings['oauth2_custom_label'] = 'OAuth2';
569 + }
570 + if ( ! array_key_exists( 'oauth2_clientid', $auth_multisite_settings ) ) {
571 + $auth_multisite_settings['oauth2_clientid'] = '';
572 + }
573 + if ( ! array_key_exists( 'oauth2_clientsecret', $auth_multisite_settings ) ) {
574 + $auth_multisite_settings['oauth2_clientsecret'] = '';
575 + }
576 + if ( ! array_key_exists( 'oauth2_hosteddomain', $auth_multisite_settings ) ) {
577 + $auth_multisite_settings['oauth2_hosteddomain'] = '';
578 + }
579 + if ( ! array_key_exists( 'oauth2_tenant_id', $auth_multisite_settings ) ) {
580 + $auth_multisite_settings['oauth2_tenant_id'] = 'common';
581 + }
582 + if ( ! array_key_exists( 'oauth2_url_authorize', $auth_multisite_settings ) ) {
583 + $auth_multisite_settings['oauth2_url_authorize'] = '';
584 + }
585 + if ( ! array_key_exists( 'oauth2_url_token', $auth_multisite_settings ) ) {
586 + $auth_multisite_settings['oauth2_url_token'] = '';
587 + }
588 + if ( ! array_key_exists( 'oauth2_url_resource', $auth_multisite_settings ) ) {
589 + $auth_multisite_settings['oauth2_url_resource'] = '';
590 + }
465 591 if ( ! array_key_exists( 'google_clientid', $auth_multisite_settings ) ) {
466 592 $auth_multisite_settings['google_clientid'] = '';
467 593 }
468 594 if ( ! array_key_exists( 'google_clientsecret', $auth_multisite_settings ) ) {
@@ -482,10 +608,13 @@
482 608 }
483 609 if ( ! array_key_exists( 'cas_path', $auth_multisite_settings ) ) {
484 610 $auth_multisite_settings['cas_path'] = '';
485 611 }
612 + if ( ! array_key_exists( 'cas_method', $auth_multisite_settings ) ) {
613 + $auth_multisite_settings['cas_method'] = Options\External\Cas::get_instance()->sanitize_cas_method();
614 + }
486 615 if ( ! array_key_exists( 'cas_version', $auth_multisite_settings ) ) {
487 - $auth_multisite_settings['cas_version'] = 'SAML_VERSION_1_1';
616 + $auth_multisite_settings['cas_version'] = Options\External\Cas::get_instance()->sanitize_cas_version();
488 617 }
489 618 if ( ! array_key_exists( 'cas_attr_email', $auth_multisite_settings ) ) {
490 619 $auth_multisite_settings['cas_attr_email'] = '';
491 620 }
@@ -515,8 +644,11 @@
515 644 }
516 645 if ( ! array_key_exists( 'ldap_search_base', $auth_multisite_settings ) ) {
517 646 $auth_multisite_settings['ldap_search_base'] = '';
518 647 }
648 + if ( ! array_key_exists( 'ldap_search_filter', $auth_multisite_settings ) ) {
649 + $auth_multisite_settings['ldap_search_filter'] = '';
650 + }
519 651 if ( ! array_key_exists( 'ldap_uid', $auth_multisite_settings ) ) {
520 652 $auth_multisite_settings['ldap_uid'] = 'uid';
521 653 }
522 654 if ( ! array_key_exists( 'ldap_attr_email', $auth_multisite_settings ) ) {
@@ -539,8 +671,11 @@
539 671 }
540 672 if ( ! array_key_exists( 'ldap_attr_update_on_login', $auth_multisite_settings ) ) {
541 673 $auth_multisite_settings['ldap_attr_update_on_login'] = '';
542 674 }
675 + if ( ! array_key_exists( 'ldap_test_user', $auth_multisite_settings ) ) {
676 + $auth_multisite_settings['ldap_test_user'] = '';
677 + }
543 678 // Advanced defaults.
544 679 if ( ! array_key_exists( 'advanced_lockouts', $auth_multisite_settings ) ) {
545 680 $auth_multisite_settings['advanced_lockouts'] = array(
546 681 'attempts_1' => 10,
@@ -552,8 +687,11 @@
552 687 }
553 688 if ( ! array_key_exists( 'advanced_hide_wp_login', $auth_multisite_settings ) ) {
554 689 $auth_multisite_settings['advanced_hide_wp_login'] = '';
555 690 }
691 + if ( ! array_key_exists( 'advanced_disable_wp_login', $auth_multisite_settings ) ) {
692 + $auth_multisite_settings['advanced_disable_wp_login'] = '';
693 + }
556 694 if ( ! array_key_exists( 'advanced_users_per_page', $auth_multisite_settings ) ) {
557 695 $auth_multisite_settings['advanced_users_per_page'] = 20;
558 696 }
559 697 if ( ! array_key_exists( 'advanced_users_sort_by', $auth_multisite_settings ) ) {
@@ -576,14 +714,12 @@
576 714
577 715 /**
578 716 * List sanitizer.
579 717 *
580 - * @param array $list Array of users to sanitize.
581 - * @param string $side_effect Set to 'update roles' if role syncing should be performed.
582 - * @param string $multisite_mode Set to 'multisite' to sync roles on all sites the user belongs to.
583 - * @return array Array of sanitized users.
718 + * @param array $list Array of users to sanitize.
719 + * @return array Array of sanitized users.
584 720 */
585 - public function sanitize_user_list( $list, $side_effect = 'none', $multisite_mode = 'single' ) {
721 + public function sanitize_user_list( $list ) {
586 722 // If it's not a list, make it so.
587 723 if ( ! is_array( $list ) ) {
588 724 $list = array();
589 725 }
@@ -590,21 +726,8 @@
590 726 foreach ( $list as $key => $user_info ) {
591 727 if ( strlen( $user_info['email'] ) < 1 ) {
592 728 // Make sure there are no empty entries in the list.
593 729 unset( $list[ $key ] );
594 - } elseif ( 'update roles' === $side_effect ) {
595 - // Make sure the WordPress user accounts have the same role
596 - // as that indicated in the list.
597 - $wp_user = get_user_by( 'email', $user_info['email'] );
598 - if ( $wp_user ) {
599 - if ( is_multisite() && 'multisite' === $multisite_mode ) {
600 - foreach ( get_blogs_of_user( $wp_user->ID ) as $blog ) {
601 - add_user_to_blog( $blog->userblog_id, $wp_user->ID, $user_info['role'] );
602 - }
603 - } else {
604 - $wp_user->set_role( $user_info['role'] );
605 - }
606 - }
607 730 }
608 731 }
609 732 return $list;
610 733 }
@@ -643,8 +766,11 @@
643 766
644 767 // Sanitize Send welcome email (checkbox: value can only be '1' or empty string).
645 768 $auth_settings['access_should_email_approved_users'] = array_key_exists( 'access_should_email_approved_users', $auth_settings ) && strlen( $auth_settings['access_should_email_approved_users'] ) > 0 ? '1' : '';
646 769
770 + // Sanitize Enable OAuth2 Logins (checkbox: value can only be '1' or empty string).
771 + $auth_settings['oauth2'] = array_key_exists( 'oauth2', $auth_settings ) && strlen( $auth_settings['oauth2'] ) > 0 ? '1' : '';
772 +
647 773 // Sanitize Enable Google Logins (checkbox: value can only be '1' or empty string).
648 774 $auth_settings['google'] = array_key_exists( 'google', $auth_settings ) && strlen( $auth_settings['google'] ) > 0 ? '1' : '';
649 775
650 776 // Sanitize Enable CAS Logins (checkbox: value can only be '1' or empty string).
@@ -655,10 +781,12 @@
655 781
656 782 // Sanitize CAS Port (int).
657 783 $auth_settings['cas_port'] = filter_var( $auth_settings['cas_port'], FILTER_SANITIZE_NUMBER_INT );
658 784
659 - // Sanitize CAS attribute update (checkbox: value can only be '1' or empty string).
660 - $auth_settings['cas_attr_update_on_login'] = array_key_exists( 'cas_attr_update_on_login', $auth_settings ) && strlen( $auth_settings['cas_attr_update_on_login'] ) > 0 ? '1' : '';
785 + // Sanitize CAS attribute update (select: value can only be 'update-if-empty', '1', or empty string).
786 + if ( ! isset( $auth_settings['cas_attr_update_on_login'] ) || ! in_array( $auth_settings['cas_attr_update_on_login'], array( '', '1', 'update-if-empty' ), true ) ) {
787 + $auth_settings['cas_attr_update_on_login'] = '';
788 + }
661 789
662 790 // Sanitize CAS auto-login (checkbox: value can only be '1' or empty string).
663 791 $auth_settings['cas_auto_login'] = array_key_exists( 'cas_auto_login', $auth_settings ) && strlen( $auth_settings['cas_auto_login'] ) > 0 ? '1' : '';
664 792
@@ -667,11 +795,8 @@
667 795
668 796 // Sanitize Enable LDAP Logins (checkbox: value can only be '1' or empty string).
669 797 $auth_settings['ldap'] = array_key_exists( 'ldap', $auth_settings ) && strlen( $auth_settings['ldap'] ) > 0 ? '1' : '';
670 798
671 - // Sanitize LDAP Host setting.
672 - $auth_settings['ldap_host'] = filter_var( $auth_settings['ldap_host'], FILTER_SANITIZE_URL );
673 -
674 799 // Sanitize LDAP Port (int).
675 800 $auth_settings['ldap_port'] = filter_var( $auth_settings['ldap_port'], FILTER_SANITIZE_NUMBER_INT );
676 801
677 802 // Sanitize LDAP TLS (checkbox: value can only be '1' or empty string).
@@ -688,10 +813,12 @@
688 813 // encrypt the directory user password for some minor obfuscation in the database.
689 814 $auth_settings['ldap_password'] = Helper::encrypt( $auth_settings['ldap_password'] );
690 815 }
691 816
692 - // Sanitize LDAP attribute update (checkbox: value can only be '1' or empty string).
693 - $auth_settings['ldap_attr_update_on_login'] = array_key_exists( 'ldap_attr_update_on_login', $auth_settings ) && strlen( $auth_settings['ldap_attr_update_on_login'] ) > 0 ? '1' : '';
817 + // Sanitize LDAP attribute update (select: value can only be 'update-if-empty', '1', or empty string).
818 + if ( ! isset( $auth_settings['ldap_attr_update_on_login'] ) || ! in_array( $auth_settings['ldap_attr_update_on_login'], array( '', '1', 'update-if-empty' ), true ) ) {
819 + $auth_settings['ldap_attr_update_on_login'] = '';
820 + }
694 821
695 822 // Make sure public pages is an empty array if it's empty.
696 823 // Note: this option doesn't exist in multisite options, so we first
697 824 // check to see if it exists.
@@ -698,16 +825,22 @@
698 825 if ( array_key_exists( 'access_public_pages', $auth_settings ) && ! is_array( $auth_settings['access_public_pages'] ) ) {
699 826 $auth_settings['access_public_pages'] = array();
700 827 }
701 828
702 - // Make sure all lockout options are integers (attempts_1,
703 - // duration_1, attempts_2, duration_2, reset_duration).
829 + // Make sure all lockout options are integers (attempts_1, duration_1,
830 + // attempts_2, duration_2, reset_duration). Default to 0 if not.
704 831 foreach ( $auth_settings['advanced_lockouts'] as $key => $value ) {
705 832 $auth_settings['advanced_lockouts'][ $key ] = filter_var( $value, FILTER_SANITIZE_NUMBER_INT );
833 + if ( empty( $auth_settings['advanced_lockouts'][ $key ] ) ) {
834 + $auth_settings['advanced_lockouts'][ $key ] = 0;
835 + }
706 836 }
707 837
708 838 // Sanitize Hide WordPress logins (checkbox: value can only be '1' or empty string).
709 839 $auth_settings['advanced_hide_wp_login'] = array_key_exists( 'advanced_hide_wp_login', $auth_settings ) && strlen( $auth_settings['advanced_hide_wp_login'] ) > 0 ? '1' : '';
840 +
841 + // Sanitize Disable WordPress logins (checkbox: value can only be '1' or empty string).
842 + $auth_settings['advanced_disable_wp_login'] = array_key_exists( 'advanced_disable_wp_login', $auth_settings ) && strlen( $auth_settings['advanced_disable_wp_login'] ) > 0 ? '1' : '';
710 843
711 844 // Sanitize Users per page (text: value can only int from 1 to MAX_INT).
712 845 $auth_settings['advanced_users_per_page'] = array_key_exists( 'advanced_users_per_page', $auth_settings ) && intval( $auth_settings['advanced_users_per_page'] ) > 0 ? intval( $auth_settings['advanced_users_per_page'] ) : 1;
713 846