PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.7.4
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.7.4
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
templately / includes / Utils / AuthErrorCode.php

AuthErrorCode.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.7.4, at includes/Utils/AuthErrorCode.php

70 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Utils;
4
5 defined( 'ABSPATH' ) || exit;
6
7 /**
8 * The codes the Google sign-in callback may hand back through the redirect URL.
9 *
10 * Only a code travels. The callback used to put the failure PROSE in an
11 * `error_message` query parameter, which the sign-in screen then rendered as
12 * markup — a reflected XSS anyone could fire by getting an administrator to
13 * open a crafted admin URL. A code cannot carry a payload: the React side
14 * matches it against this same list and discards anything it does not
15 * recognise, and the copy for each one lives in the plugin.
16 *
17 * Values mirror `includes/Utils/Response/ErrorCode.php` on the `staging` branch
18 * so the two converge when that work lands on the release line.
19 */
20 class AuthErrorCode {
21
22 /**
23 * The state token was missing, expired, or minted for another user.
24 */
25 const AUTH_STATE_INVALID = 'templately_auth_state_invalid';
26
27 /**
28 * The callback arrived without an API key to connect with.
29 */
30 const AUTH_MISSING_API_KEY = 'templately_auth_missing_api_key';
31
32 /**
33 * Google itself refused — it returns its reason in `?error=`, which we
34 * deliberately do not forward.
35 */
36 const AUTH_PROVIDER_FAILED = 'templately_auth_provider_failed';
37
38 /**
39 * The key was rejected when we tried to connect with it. Also the catch-all:
40 * anything without a code of its own collapses here, so no upstream-authored
41 * string ever needs to reach the URL.
42 */
43 const INVALID_API_KEY = 'templately_invalid_api_key';
44
45 /**
46 * Every code this class defines.
47 *
48 * @return string[]
49 */
50 public static function all() {
51 return [
52 self::AUTH_STATE_INVALID,
53 self::AUTH_MISSING_API_KEY,
54 self::AUTH_PROVIDER_FAILED,
55 self::INVALID_API_KEY,
56 ];
57 }
58
59 /**
60 * Whether a value is one of ours.
61 *
62 * @param mixed $code Candidate code, typically straight off the query string.
63 *
64 * @return bool
65 */
66 public static function exists( $code ) {
67 return is_string( $code ) && in_array( $code, self::all(), true );
68 }
69 }
70