make webfinger route available unsigned

This commit is contained in:
Django Doucet 2023-05-05 23:44:15 -06:00
parent b0edf9a765
commit f79200ef27

View file

@ -79,22 +79,22 @@ class Server {
* @return mixed|\WP_Error * @return mixed|\WP_Error
*/ */
public static function authorize_activitypub_requests( $response, $handler, $request ) { public static function authorize_activitypub_requests( $response, $handler, $request ) {
$route = $request->get_route();
$maybe_activitypub = $request->get_route(); if ( str_starts_with( $route, '/activitypub' ) ) {
if ( str_starts_with( $maybe_activitypub, '/activitypub' ) ) {
if ( 'POST' === $request->get_method() ) { if ( 'POST' === $request->get_method() ) {
$verified_request = Signature::verify_http_signature( $request ); $verified_request = Signature::verify_http_signature( $request );
if ( \is_wp_error( $verified_request ) ) { if ( \is_wp_error( $verified_request ) ) {
return $verified_request; return $verified_request;
} }
} else { } else {
// SecureMode/Authorized fetch. if ( '/activitypub/1.0/webfinger' !== $route ) {
$secure_mode = \get_option( 'activitypub_use_secure_mode', '0' ); // SecureMode/Authorized fetch.
if ( $secure_mode ) { $secure_mode = \get_option( 'activitypub_use_secure_mode', '0' );
$verified_request = Signature::verify_http_signature( $request ); if ( $secure_mode ) {
if ( \is_wp_error( $verified_request ) ) { $verified_request = Signature::verify_http_signature( $request );
return $verified_request; if ( \is_wp_error( $verified_request ) ) {
return $verified_request;
}
} }
} }
} }