PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.8
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / myyoast-client / application / grants / authorization-code-grant.php

authorization-code-grant.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.8, at src/myyoast-client/application/grants/authorization-code-grant.php

80 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
4 namespace Yoast\WP\SEO\MyYoast_Client\Application\Grants;
5
6 use SensitiveParameter;
7
8 /**
9 * Grant strategy for the Authorization Code flow (RFC 6749 Section 4.1).
10 *
11 * Provides the authorization code, redirect URI, and PKCE code verifier
12 * for the token exchange request.
13 */
14 class Authorization_Code_Grant implements Grant_Interface {
15
16 /**
17 * The authorization code received from the callback.
18 *
19 * @var string
20 */
21 private $code;
22
23 /**
24 * The redirect URI used in the original authorization request.
25 *
26 * @var string
27 */
28 private $redirect_uri;
29
30 /**
31 * The PKCE code verifier for this authorization flow.
32 *
33 * @var string
34 */
35 private $code_verifier;
36
37 /**
38 * Authorization_Code_Grant constructor.
39 *
40 * @param string $code The authorization code.
41 * @param string $redirect_uri The redirect URI.
42 * @param string $code_verifier The PKCE code verifier.
43 */
44 public function __construct(
45 // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPNativeAttributeFound -- No-op on PHP < 8.2; redacts parameter from stack traces on PHP 8.2+.
46 #[SensitiveParameter]
47 string $code,
48 string $redirect_uri,
49 // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPNativeAttributeFound -- No-op on PHP < 8.2; redacts parameter from stack traces on PHP 8.2+.
50 #[SensitiveParameter]
51 string $code_verifier
52 ) {
53 $this->code = $code;
54 $this->redirect_uri = $redirect_uri;
55 $this->code_verifier = $code_verifier;
56 }
57
58 /**
59 * Returns the grant type identifier.
60 *
61 * @return string
62 */
63 public function get_grant_type(): string {
64 return 'authorization_code';
65 }
66
67 /**
68 * Returns the grant-specific parameters.
69 *
70 * @return array<string, string>
71 */
72 public function get_grant_params(): array {
73 return [
74 'code' => $this->code,
75 'redirect_uri' => $this->redirect_uri,
76 'code_verifier' => $this->code_verifier,
77 ];
78 }
79 }
80