mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-18 17:33:43 +03:00
Email: Send no-cache headers when auth token present for security.
This commit is contained in:
parent
18228d367c
commit
7e89d1794a
|
@ -37,6 +37,20 @@ const TOKEN_PREFIX = '5ftf_auth_token_';
|
|||
// Longer than `get_password_reset_key()` just to be safe. See https://core.trac.wordpress.org/ticket/43546#comment:34
|
||||
const TOKEN_LENGTH = 32;
|
||||
|
||||
add_action( 'wp_head', __NAMESPACE__ . '\prevent_caching_auth_tokens', 99 );
|
||||
|
||||
/**
|
||||
* Prevent caching mechanisms from caching authentication tokens.
|
||||
*
|
||||
* Search engines would often be too slow to index tokens before they expire, but other mechanisms like Varnish,
|
||||
* etc could create situations where they're leaked to others.
|
||||
*/
|
||||
function prevent_caching_auth_tokens() {
|
||||
if ( isset( $_GET['auth_token'] ) || isset( $_POST['auth_token'] ) ) {
|
||||
nocache_headers();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap `wp_mail()` with shared functionality.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue