discovery = $discovery; $this->client_registration = $client_registration; $this->client_authenticator = $client_authenticator; $this->oauth_server_client = $oauth_server_client; $this->logger = new NullLogger(); } /** * Revokes a token at the authorization server. * * @param string $token The token to revoke. * @param string $token_type_hint A Token_Type_Hint constant. * * @return bool True if the revocation request was sent (regardless of server response). */ public function revoke( // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPNativeAttributeFound -- No-op on PHP < 8.2; redacts parameter from stack traces on PHP 8.2+. #[SensitiveParameter] string $token, string $token_type_hint = Token_Type_Hint::REFRESH_TOKEN ): bool { try { $registered_client = $this->client_registration->get_registered_client(); if ( $registered_client === null ) { return false; } $revocation_endpoint = $this->discovery->get_document()->get_revocation_endpoint(); $client_assertion = $this->client_authenticator->create_client_assertion( $registered_client->get_client_id(), $revocation_endpoint, ); $body = [ 'token' => $token, 'token_type_hint' => $token_type_hint, 'client_id' => $registered_client->get_client_id(), 'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer', 'client_assertion' => $client_assertion, ]; $this->oauth_server_client->request( 'POST', $revocation_endpoint, [ 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded' ], 'body' => $body, 'dpop' => true, ], ); return true; } catch ( Exception $e ) { $this->logger->warning( 'Token revocation failed ({token_type_hint}): {error}', [ 'token_type_hint' => $token_type_hint, 'error' => $e->getMessage(), ], ); return false; } } }