diff --git a/projects/plugins/jetpack/changelog/rm-sso-legacy-code b/projects/plugins/jetpack/changelog/rm-sso-legacy-code new file mode 100644 index 0000000000000..741e9967c09c1 --- /dev/null +++ b/projects/plugins/jetpack/changelog/rm-sso-legacy-code @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +SSO: remove legacy codebase in favor of the newer SSO codebase introduced in Jetpack 13.5 diff --git a/projects/plugins/jetpack/modules/sso.php b/projects/plugins/jetpack/modules/sso.php index d2285b680404a..6f2d6f56629fd 100644 --- a/projects/plugins/jetpack/modules/sso.php +++ b/projects/plugins/jetpack/modules/sso.php @@ -25,10 +25,3 @@ function () { Jetpack::enable_module_configurable( __FILE__ ); } ); - -/** - * Legacy, deprecated class. - * - * @deprecated 13.5 - */ -class Jetpack_SSO extends SSO {} diff --git a/projects/plugins/jetpack/modules/sso/class-jetpack-force-2fa.php b/projects/plugins/jetpack/modules/sso/class-jetpack-force-2fa.php deleted file mode 100644 index 422f4b543d0f6..0000000000000 --- a/projects/plugins/jetpack/modules/sso/class-jetpack-force-2fa.php +++ /dev/null @@ -1,70 +0,0 @@ -is_user_connected' ); - - return ( new Manager() )->is_user_connected( $user_id ); - } - } - -endif; diff --git a/projects/plugins/jetpack/modules/sso/class.jetpack-sso-notices.php b/projects/plugins/jetpack/modules/sso/class.jetpack-sso-notices.php deleted file mode 100644 index 7210ed4ae28da..0000000000000 --- a/projects/plugins/jetpack/modules/sso/class.jetpack-sso-notices.php +++ /dev/null @@ -1,188 +0,0 @@ - General > Secure Sign On - * - * @since 2.7 - * - * @deprecated 13.5 - * - * @param string $message Error message. - * - * @return string - **/ - public static function msg_login_by_jetpack( $message ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\Manager\\SSO\\Notices::msg_login_by_jetpack' ); - - return Notices::msg_login_by_jetpack( $message ); - } - - /** - * Get the message for SSO required. - * - * @deprecated 13.5 - * - * @return string - */ - public static function get_sso_required_message() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\Manager\\SSO\\Notices::get_sso_required_message' ); - - return Notices::get_sso_required_message(); - } - - /** - * Message displayed when the user can not be found after approving the SSO process on WordPress.com - * - * @deprecated 13.5 - * - * @param string $message Error message. - * - * @return string - */ - public static function cant_find_user( $message ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\Manager\\SSO\\Notices::cant_find_user' ); - - return Notices::cant_find_user( $message ); - } - - /** - * Error message that is displayed when the current site is in an identity crisis and SSO can not be used. - * - * @since 4.4.0 - * - * @deprecated 13.5 - * - * @param string $message Error message. - * - * @return string - */ - public static function sso_not_allowed_in_staging( $message ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\Manager\\SSO\\Notices::sso_not_allowed_in_staging' ); - // @phan-suppress-next-line PhanDeprecatedFunction - return Notices::sso_not_allowed_in_staging( $message ); - } - } - -endif; diff --git a/projects/plugins/jetpack/modules/sso/class.jetpack-sso-user-admin.php b/projects/plugins/jetpack/modules/sso/class.jetpack-sso-user-admin.php deleted file mode 100644 index c3e5aa4c9e3d5..0000000000000 --- a/projects/plugins/jetpack/modules/sso/class.jetpack-sso-user-admin.php +++ /dev/null @@ -1,254 +0,0 @@ -jetpack_new_users_styles' ); - } - - /** - * Intercept the arguments for building the table, and create WP_User_Query instance - * - * @deprecated 13.5 - * - * @param array $args The search arguments. - */ - public function set_user_query( $args ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->set_user_query' ); - } - - /** - * Revokes WordPress.com invitation. - * - * @deprecated 13.5 - * - * @param int $user_id The user ID. - */ - public function revoke_user_invite( $user_id ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->revoke_user_invite' ); - } - - /** - * Renders invitations errors/success messages in users.php. - * - * @deprecated 13.5 - */ - public function handle_invitation_results() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->handle_invitation_results' ); - } - - /** - * Invites a user to connect to WordPress.com to allow them to log in via SSO. - * - * @deprecated 13.5 - */ - public function invite_user_to_wpcom() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->invite_user_to_wpcom' ); - } - - /** - * Revokes a user's invitation to connect to WordPress.com. - * - * @deprecated 13.5 - * - * @param string $invite_id The ID of the invite to revoke. - */ - public function send_revoke_wpcom_invite( $invite_id ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->send_revoke_wpcom_invite' ); - } - - /** - * Handles logic to revoke user invite. - * - * @deprecated 13.5 - */ - public function handle_request_revoke_invite() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->handle_request_revoke_invite' ); - } - - /** - * Handles resend user invite. - * - * @deprecated 13.5 - */ - public function handle_request_resend_invite() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->handle_request_resend_invite' ); - } - - /** - * Adds 'Revoke invite' and 'Resend invite' link to user table row actions. - * Removes 'Reset password' link. - * - * @deprecated 13.5 - * - * @param array $actions - User row actions. - * @param WP_User $user_object - User object. - */ - public function jetpack_user_table_row_actions( $actions, $user_object ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->jetpack_user_table_row_actions' ); - } - - /** - * Render the invitation email message. - * - * @deprecated 13.5 - */ - public function render_invitation_email_message() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->render_invitation_email_message' ); - } - - /** - * Render a note that wp.com invites will be automatically revoked. - * - * @deprecated 13.5 - */ - public function render_invitations_notices_for_deleted_users() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->render_invitations_notices_for_deleted_users' ); - } - - /** - * Render WordPress.com invite checkbox for new user registration. - * - * @deprecated 13.5 - * - * @param string $type The type of new user form the hook follows. - */ - public function render_wpcom_invite_checkbox( $type ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->render_wpcom_invite_checkbox' ); - } - - /** - * Render a checkbox to differentiate if a user is external. - * - * @deprecated 13.5 - * - * @param string $type The type of new user form the hook follows. - */ - public function render_wpcom_external_user_checkbox( $type ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->render_wpcom_external_user_checkbox' ); - } - - /** - * Render the custom email message form field for new user registration. - * - * @deprecated 13.5 - * - * @param string $type The type of new user form the hook follows. - */ - public function render_custom_email_message_form_field( $type ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->render_custom_email_message_form_field' ); - } - - /** - * Conditionally disable the core invitation email. - * It should be sent when SSO is disabled or when admins opt-out of WordPress.com invites intentionally. - * If the "Send User Notification" checkbox is checked, the core invitation email should be sent. - * - * @deprecated 13.5 - * - * @param boolean $send_wp_email Whether the core invitation email should be sent. - */ - public function should_send_wp_mail_new_user( $send_wp_email ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->should_send_wp_mail_new_user' ); - } - - /** - * Send user invitation to WordPress.com if user has no errors. - * - * @deprecated 13.5 - * - * @param WP_Error $errors The WP_Error object. - * @param bool $update Whether the user is being updated or not. - * @param stdClass $user The User object about to be created. - */ - public function send_wpcom_mail_user_invite( $errors, $update, $user ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->send_wpcom_mail_user_invite' ); - } - - /** - * Adds a column in the user admin table to display user connection status and actions. - * - * @deprecated 13.5 - * - * @param array $columns User list table columns. - */ - public function jetpack_user_connected_th( $columns ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->jetpack_user_connected_th' ); - } - - /** - * Check if there is cached invite for a user email. - * - * @access private - * @static - * - * @deprecated 13.5 - * - * @param string $email The user email. - */ - public static function get_pending_cached_wpcom_invite( $email ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->get_pending_cached_wpcom_invite' ); - } - - /** - * Show Jetpack SSO user connection status. - * - * @deprecated 13.5 - * - * @param string $val HTML for the column. - * @param string $col User list table column. - * @param int $user_id User ID. - */ - public function jetpack_show_connection_status( $val, $col, $user_id ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->jetpack_show_connection_status' ); - } - - /** - * Creates error notices and redirects the user to the previous page. - * - * @deprecated 13.5 - * - * @param array $query_params - query parameters added to redirection URL. - */ - public function create_error_notice_and_redirect( $query_params ) { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->create_error_notice_and_redirect' ); - } - - /** - * Style the Jetpack user rows and columns. - * - * @deprecated 13.5 - */ - public function jetpack_user_table_styles() { - _deprecated_function( __METHOD__, 'jetpack-13.5', 'Automattic\\Jetpack\\Connection\\SSO\\User_Admin->jetpack_user_table_styles' ); - } - } -endif; diff --git a/projects/plugins/jetpack/modules/sso/jetpack-sso-admin-create-user.css b/projects/plugins/jetpack/modules/sso/jetpack-sso-admin-create-user.css deleted file mode 100644 index 5a4c345238360..0000000000000 --- a/projects/plugins/jetpack/modules/sso/jetpack-sso-admin-create-user.css +++ /dev/null @@ -1,22 +0,0 @@ - -.jetpack-sso-admin-create-user-invite-message { - width: 550px; -} - -.jetpack-sso-admin-create-user-invite-message-link-sso { - text-decoration: none; -} - -#createuser .form-field textarea { - width: 25em; -} - -#createuser .form-field [type=checkbox] { - width: 1rem; -} - -#custom_email_message_description { - max-width: 25rem; - color: #646970; - font-size: 12px; -} diff --git a/projects/plugins/jetpack/modules/sso/jetpack-sso-admin-create-user.js b/projects/plugins/jetpack/modules/sso/jetpack-sso-admin-create-user.js deleted file mode 100644 index 0c8449c78c931..0000000000000 --- a/projects/plugins/jetpack/modules/sso/jetpack-sso-admin-create-user.js +++ /dev/null @@ -1,45 +0,0 @@ -document.addEventListener( 'DOMContentLoaded', function () { - const sendUserNotificationCheckbox = document.getElementById( 'send_user_notification' ); - const userExternalContractorCheckbox = document.getElementById( 'user_external_contractor' ); - const inviteUserWpcomCheckbox = document.getElementById( 'invite_user_wpcom' ); - const customEmailMessageBlock = document.getElementById( 'custom_email_message_block' ); - - if ( inviteUserWpcomCheckbox && sendUserNotificationCheckbox && customEmailMessageBlock ) { - // Toggle Send User Notification checkbox enabled/disabled based on Invite User checkbox - // Enable External Contractor checkbox if Invite User checkbox is checked - // Show/hide the external email message field. - inviteUserWpcomCheckbox.addEventListener( 'change', function () { - sendUserNotificationCheckbox.disabled = inviteUserWpcomCheckbox.checked; - if ( inviteUserWpcomCheckbox.checked ) { - sendUserNotificationCheckbox.checked = false; - if ( userExternalContractorCheckbox ) { - userExternalContractorCheckbox.disabled = false; - } - customEmailMessageBlock.style.display = 'table'; - } else { - if ( userExternalContractorCheckbox ) { - userExternalContractorCheckbox.disabled = true; - userExternalContractorCheckbox.checked = false; - } - customEmailMessageBlock.style.display = 'none'; - } - } ); - - // On load, disable Send User Notification checkbox - // and show the custom email message if Invite User checkbox is checked - if ( inviteUserWpcomCheckbox.checked ) { - sendUserNotificationCheckbox.disabled = true; - sendUserNotificationCheckbox.checked = false; - customEmailMessageBlock.style.display = 'table'; - } - - // On load, disable External Contractor checkbox - // and hide the custom email message if Invite User checkbox is unchecked - if ( ! inviteUserWpcomCheckbox.checked ) { - if ( userExternalContractorCheckbox ) { - userExternalContractorCheckbox.disabled = true; - } - customEmailMessageBlock.style.display = 'none'; - } - } -} ); diff --git a/projects/plugins/jetpack/modules/sso/jetpack-sso-login.css b/projects/plugins/jetpack/modules/sso/jetpack-sso-login.css deleted file mode 100644 index 167c0ff1c11af..0000000000000 --- a/projects/plugins/jetpack/modules/sso/jetpack-sso-login.css +++ /dev/null @@ -1,163 +0,0 @@ -#loginform { - /* We set !important because sometimes static is added inline */ - position: relative !important; - padding-bottom: 92px; -} - -.jetpack-sso-repositioned #loginform { - padding-bottom: 26px; -} - -#loginform #jetpack-sso-wrap, -#loginform #jetpack-sso-wrap * { - box-sizing: border-box; -} - - -#jetpack-sso-wrap__action, -#jetpack-sso-wrap__user{ - display: none; -} - -.jetpack-sso-form-display #jetpack-sso-wrap__action, -.jetpack-sso-form-display #jetpack-sso-wrap__user { - display: block; -} - -#jetpack-sso-wrap { - position: absolute; - bottom: 20px; - padding: 0 24px; - margin-left: -24px; - margin-right: -24px; - width: 100%; -} - -.jetpack-sso-repositioned #jetpack-sso-wrap { - position: relative; - bottom: auto; - padding: 0; - margin-top: 16px; - margin-left: 0; - margin-right: 0; -} - -.jetpack-sso-form-display #jetpack-sso-wrap { - position: relative; - bottom: auto; - padding: 0; - margin-top: 0; - margin-left: 0; - margin-right: 0; -} - -#loginform #jetpack-sso-wrap p { - color: #777777; - margin-bottom: 16px; -} - -#jetpack-sso-wrap a { - display: block; - width: 100%; - text-align: center; - text-decoration: none; -} - -#jetpack-sso-wrap .jetpack-sso-toggle.wpcom { - display: none; -} - -.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.wpcom { - display: block; -} - - -.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.default { - display: none; -} - - -.jetpack-sso-form-display #loginform > p, -.jetpack-sso-form-display #loginform > div { - display: none; -} - -.jetpack-sso-form-display #loginform #jetpack-sso-wrap { - display: block; -} - -.jetpack-sso-form-display #loginform { - padding: 26px 24px; -} - -.jetpack-sso-or { - margin-bottom: 16px; - position: relative; - text-align: center; -} - -.jetpack-sso-or:before { - background: #dcdcde; - content: ''; - height: 1px; - position: absolute; - left: 0; - top: 50%; - width: 100%; -} -.jetpack-sso-or span { - background: #fff; - color: #777; - position: relative; - padding: 0 8px; - text-transform: uppercase -} - -#jetpack-sso-wrap .button { - display: flex; - justify-content: center; - align-items: center; - height: 36px; - margin-bottom: 16px; - width: 100%; -} - -#jetpack-sso-wrap .button .genericon-wordpress { - font-size: 24px; - margin-right: 4px; -} - -#jetpack-sso-wrap__user img { - border-radius: 50%; - display: block; - margin: 0 auto 16px; -} - -#jetpack-sso-wrap__user h2 { - font-size: 21px; - font-weight: 300; - margin-bottom: 16px; - text-align: center; -} - -#jetpack-sso-wrap__user h2 span { - font-weight: bold; -} - -.jetpack-sso-wrap__reauth { - margin-bottom: 16px; -} - -.jetpack-sso-form-display #nav { - display: none; -} - -.jetpack-sso-form-display #backtoblog { - margin: 24px 0 0; -} - -.jetpack-sso-clear:after { - content: ""; - display: table; - clear: both; -} diff --git a/projects/plugins/jetpack/modules/sso/jetpack-sso-login.js b/projects/plugins/jetpack/modules/sso/jetpack-sso-login.js deleted file mode 100644 index 980741be20c42..0000000000000 --- a/projects/plugins/jetpack/modules/sso/jetpack-sso-login.js +++ /dev/null @@ -1,27 +0,0 @@ -document.addEventListener( 'DOMContentLoaded', () => { - const body = document.querySelector( 'body' ), - toggleSSO = document.querySelector( '.jetpack-sso-toggle' ), - userLogin = document.getElementById( 'user_login' ), - userPassword = document.getElementById( 'user_pass' ), - ssoWrap = document.getElementById( 'jetpack-sso-wrap' ), - loginForm = document.getElementById( 'loginform' ), - overflow = document.createElement( 'div' ); - - overflow.className = 'jetpack-sso-clear'; - - loginForm.appendChild( overflow ); - overflow.appendChild( document.querySelector( 'p.forgetmenot' ) ); - overflow.appendChild( document.querySelector( 'p.submit' ) ); - - loginForm.appendChild( ssoWrap ); - body.classList.add( 'jetpack-sso-repositioned' ); - - toggleSSO.addEventListener( 'click', e => { - e.preventDefault(); - body.classList.toggle( 'jetpack-sso-form-display' ); - if ( ! body.classList.contains( 'jetpack-sso-form-display' ) ) { - userLogin.focus(); - userPassword.disabled = false; - } - } ); -} ); diff --git a/projects/plugins/jetpack/modules/sso/jetpack-sso-users.js b/projects/plugins/jetpack/modules/sso/jetpack-sso-users.js deleted file mode 100644 index bf050b5237ba4..0000000000000 --- a/projects/plugins/jetpack/modules/sso/jetpack-sso-users.js +++ /dev/null @@ -1,12 +0,0 @@ -document.addEventListener( 'DOMContentLoaded', function () { - document - .querySelectorAll( '.jetpack-sso-invitation-tooltip-icon, #user_jetpack' ) - .forEach( function ( tooltip ) { - tooltip.addEventListener( 'mouseenter', function () { - this.querySelector( '.jetpack-sso-invitation-tooltip' ).style.display = 'block'; - } ); - tooltip.addEventListener( 'mouseleave', function () { - this.querySelector( '.jetpack-sso-invitation-tooltip' ).style.display = 'none'; - } ); - } ); -} ); diff --git a/projects/plugins/jetpack/tools/webpack.config.css.js b/projects/plugins/jetpack/tools/webpack.config.css.js index 7d29e86a7672d..e95602e091032 100644 --- a/projects/plugins/jetpack/tools/webpack.config.css.js +++ b/projects/plugins/jetpack/tools/webpack.config.css.js @@ -171,8 +171,6 @@ for ( const name of [ 'modules/videopress/css/videopress-editor-style', 'modules/widget-visibility/widget-conditions/widget-conditions', 'modules/widgets/gallery/css/admin', - 'modules/sso/jetpack-sso-login', - 'modules/sso/jetpack-sso-admin-create-user', 'modules/masterbar/admin-menu/admin-menu', 'modules/masterbar/admin-menu/admin-menu-nav-unification', ] ) {