Changeset 2310258
- Timestamp:
- 05/22/2020 02:58:57 PM (6 years ago)
- Location:
- multisite-multidomain-single-sign-on/trunk
- Files:
-
- 2 edited
-
multisite-multidomain-single-sign-on.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
multisite-multidomain-single-sign-on/trunk/multisite-multidomain-single-sign-on.php
r2305137 r2310258 3 3 Plugin Name: Multisite Multidomain Single Sign On 4 4 Description: Automatically sign the user in to separate-domain sites of the same multisite installation, when switching sites using the My Sites links in the admin menu. Note that the user already has to be logged into a site in the network, this plugin just cuts down on having to log in again due to cookie isolation between domains. Note: This plugin must be installed on all sites in a network in order to work. 5 Version: 1. 15 Version: 1.2 6 6 Requires at least: 5.0 7 7 Tested up to: 5.4.1 … … 83 83 $current_user = wp_get_current_user(); 84 84 $expires = strtotime('+2 minutes'); 85 $hash = $this->hash(intval($current_user->ID) . '||' . intval($expires)); 85 86 /* 87 * The user's password hash is a user-specific, expirable, private piece of information 88 * that prevents brute force hacking of the salt if an attacker has the query parameters. 89 */ 90 $user_pass_hash = $this->get_user_password_hash($current_user->ID); 91 if(empty($user_pass_hash)) { 92 wp_die('Single Sign On failed. Your password hash was empty. Try changing your Wordpress password.'); 93 } 94 95 $hash = $this->hash(implode('||', [intval($current_user->ID), intval($expires), $user_pass_hash])); 86 96 if(empty($hash)) { 87 97 wp_die('Single Sign On failed. The network needs a secure salt.'); … … 116 126 117 127 if($expires < time()) { 118 wp_die('Your Single Si ngOn link has expired. Please return to the dashboard and try again.');128 wp_die('Your Single Sign On link has expired. Please return to the dashboard and try again.'); 119 129 } 120 $expected_hash = $this->hash($user_id . '||' . $expires); 130 $user_pass_hash = $this->get_user_password_hash($user_id); 131 $expected_hash = $this->hash(implode('||', [intval($user_id), intval($expires), $user_pass_hash])); 121 132 if(empty($expected_hash)) { 122 133 wp_die('Single Sign On failed. The network needs a secure salt.'); … … 137 148 138 149 /** 150 * @param int $uid 151 * @return string|null 152 */ 153 protected function get_user_password_hash($uid) { 154 global $wpdb; 155 return $wpdb->get_var($wpdb->prepare("SELECT user_pass FROM {$wpdb->users} WHERE ID = %d", $uid)); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.user_meta__wpdb__users 156 } 157 158 /** 139 159 * Create a secure hash that can only be recreated from this Wordpress install's secret salt. 140 160 * @param string $thing -
multisite-multidomain-single-sign-on/trunk/readme.txt
r2305137 r2310258 6 6 Tested up to: 5.4.1 7 7 Requires PHP: 7.0 8 Stable tag: 1. 18 Stable tag: 1.2 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.