Making WordPress.org

Changeset 14070


Ignore:
Timestamp:
09/23/2024 07:25:15 AM (15 months ago)
Author:
dd32
Message:

Login: Lower the enable-2fa nag interval to 2 days, and set login sessions to a maximum of 2 days until they do so.

See https://make.wordpress.org/plugins/2024/09/04/upcoming-security-changes-for-plugin-and-theme-authors-on-wordpress-org/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/wporg-sso/wp-plugin.php

    r14018 r14070  
    9090                add_action( 'profile_update', array( $this, 'record_last_password_change' ), 10, 3 );
    9191                add_action( 'wp_set_password', array( $this, 'record_last_password_change_reset' ), 10, 3 );
     92
     93                add_filter( 'auth_cookie_expiration', array( $this, 'auth_cookie_expiration' ), 10, 2 );
    9294
    9395                add_action( 'login_form_logout', array( $this, 'login_form_logout' ) );
     
    843845
    844846        /**
     847         * Shorten the session timeout for users who haven't setup 2FA.
     848         *
     849         * Acts as if the user didn't check the remember-me box.
     850         */
     851        public function auth_cookie_expiration( $expiration, $user_id ) {
     852            $user = get_user_by( 'id', $user_id );
     853
     854            if ( $user && user_should_2fa( $user ) && ! Two_Factor_Core::is_user_using_two_factor( $user_id ) ) {
     855                $expiration = min( $expiration, 2 * DAY_IN_SECONDS );
     856            }
     857
     858            return $expiration;
     859        }
     860
     861        /**
    845862         * Redirects the user to a "please enable 2fa" page after login.
    846863         */
     
    862879            // If the user doesn't REQUIRE 2FA, only nag ever so often.
    863880            if ( ! user_requires_2fa( $user ) ) {
    864                 $nag_interval = WEEK_IN_SECONDS;
     881                $nag_interval = 2 * DAY_IN_SECONDS;
    865882                $last_nagged  = (int) get_user_meta( $user->ID, 'last_2fa_nag', true );
    866883                if ( $last_nagged && $last_nagged > ( time() - $nag_interval ) ) {
Note: See TracChangeset for help on using the changeset viewer.