Yoast\WP\SEO\MyYoast_Client\User_Interface

Auth_Command::rotate_keyspublicYoast 1.0

Rotates cryptographic key pairs.

Rotates the registration key pair (server roundtrip) and/or the DPoP key pair (local only).

OPTIONS

[--registration]
Rotate the registration (private_key_jwt) key pair. Requires a server roundtrip.
[--dpop]
Rotate the DPoP proof key pair (local only).
[--all]
Rotate all key pairs.
[--yes]
Skip confirmation prompt.

EXAMPLES

wp yoast auth rotate-keys --registration
wp yoast auth rotate-keys --dpop
wp yoast auth rotate-keys --all

Метод класса: Auth_Command{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$Auth_Command = new Auth_Command();
$Auth_Command->rotate_keys( $args, $assoc_args ): void;
$args
.
По умолчанию: null
$assoc_args
.
По умолчанию: null

Код Auth_Command::rotate_keys() Yoast 27.7

public function rotate_keys( $args = null, $assoc_args = null ): void {
	$rotate_registration = isset( $assoc_args['registration'] ) || isset( $assoc_args['all'] );
	$rotate_dpop         = isset( $assoc_args['dpop'] ) || isset( $assoc_args['all'] );

	if ( ! $rotate_registration && ! $rotate_dpop ) {
		WP_CLI::error( 'Specify --registration, --dpop, or --all.' );
	}

	WP_CLI::confirm( 'This will rotate the specified key pairs. Existing tokens may be invalidated. Proceed?', $assoc_args );

	if ( $rotate_registration ) {
		if ( ! $this->myyoast_client->is_registered() ) {
			WP_CLI::error( 'Not registered. Run "wp yoast auth register" first.' );
		}

		try {
			$client = $this->myyoast_client->rotate_registration_keys();
			WP_CLI::log( 'Registration keys rotated. Client ID: ' . $client->get_client_id() );
		} catch ( Exception $e ) {
			WP_CLI::error( 'Registration key rotation failed: ' . $e->getMessage() );
			return;
		}
	}

	if ( $rotate_dpop ) {
		$this->myyoast_client->rotate_dpop_keys();
		WP_CLI::log( 'DPoP keys rotated.' );
	}

	WP_CLI::success( 'Key rotation complete.' );
}