Skip to content

Commit 976dc65

Browse files
committed
Don't fallback to DB info for secret key. Allow expiration grace period for AJAX requests. see WordPress#5367
git-svn-id: https://develop.svn.wordpress.org/trunk@6471 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 22eb9c1 commit 976dc65

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

wp-config-sample.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
77
define('DB_CHARSET', 'utf8');
88
define('DB_COLLATE', '');
9+
10+
// Change SECRET_KEY to a unique phrase. You won't have to remember it later,
11+
// so make it long and complicated. You can visit https://www.grc.com/passwords.htm
12+
// to get a phrase generated for you.
913
define('SECRET_KEY', ''); // Change this to a unique phrase.
1014

1115
// You can have multiple installations in one database if you give each a unique prefix

wp-includes/pluggable.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ function wp_validate_auth_cookie($cookie = '') {
336336

337337
$expired = $expiration;
338338

339-
// Allow a grace period for POST requests
340-
if ( 'POST' == $_SERVER['REQUEST_METHOD'] )
339+
// Allow a grace period for POST and AJAX requests
340+
if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] )
341341
$expired += 3600;
342342

343343
if ( $expired < time() )
@@ -699,18 +699,17 @@ function wp_create_nonce($action = -1) {
699699

700700
if ( !function_exists('wp_salt') ) :
701701
function wp_salt() {
702+
703+
if ( defined('SECRET_KEY') && '' != SECRET_KEY )
704+
return SECRET_KEY;
705+
702706
$salt = get_option('secret');
703707
if ( empty($salt) ) {
704708
$salt = wp_generate_password();
705709
update_option('secret', $salt);
706710
}
707711

708-
if ( !defined('SECRET_KEY') || '' == SECRET_KEY )
709-
$secret_key = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
710-
else
711-
$secret_key = SECRET_KEY;
712-
713-
return $salt . $secret_key;
712+
return $salt;
714713
}
715714
endif;
716715

0 commit comments

Comments
 (0)