| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 |
namespace Yoast\WP\SEO\AI\Authorization\User_Interface; |
| 5 |
|
| 6 |
/** |
| 7 |
* Registers the callback route used in the authorization process. |
| 8 |
* |
| 9 |
* @makePublic |
| 10 |
* |
| 11 |
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded |
| 12 |
*/ |
| 13 |
class Refresh_Callback_Route extends Abstract_Callback_Route { |
| 14 |
|
| 15 |
/** |
| 16 |
* The prefix for this route. |
| 17 |
* |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
public const ROUTE_PREFIX = '/ai_generator/refresh_callback'; |
| 21 |
|
| 22 |
/** |
| 23 |
* Registers routes with WordPress. |
| 24 |
* |
| 25 |
* @return void |
| 26 |
*/ |
| 27 |
public function register_routes() { |
| 28 |
\register_rest_route( |
| 29 |
parent::ROUTE_NAMESPACE, |
| 30 |
self::ROUTE_PREFIX, |
| 31 |
[ |
| 32 |
'methods' => 'POST', |
| 33 |
'args' => [ |
| 34 |
'access_jwt' => [ |
| 35 |
'required' => true, |
| 36 |
'type' => 'string', |
| 37 |
'description' => 'The access JWT.', |
| 38 |
], |
| 39 |
'refresh_jwt' => [ |
| 40 |
'required' => true, |
| 41 |
'type' => 'string', |
| 42 |
'description' => 'The JWT to be used when the access JWT needs to be refreshed.', |
| 43 |
], |
| 44 |
'code_challenge' => [ |
| 45 |
'required' => true, |
| 46 |
'type' => 'string', |
| 47 |
'description' => 'The SHA266 of the verification code used to check the authenticity of a callback call.', |
| 48 |
], |
| 49 |
'user_id' => [ |
| 50 |
'required' => true, |
| 51 |
'type' => 'integer', |
| 52 |
'description' => 'The id of the user associated to the code verifier.', |
| 53 |
], |
| 54 |
], |
| 55 |
'callback' => [ $this, 'callback' ], |
| 56 |
'permission_callback' => '__return_true', |
| 57 |
], |
| 58 |
); |
| 59 |
} |
| 60 |
} |
| 61 |
|