File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -293,6 +293,20 @@ public static function use_custom_user_expiration( $expiration ) {
293293 */
294294 public static function add_tokens_to_graphql_response_headers ( $ headers ) {
295295
296+ $ should_return_tokens = false ;
297+
298+ /**
299+ * If the request _is_ SSL, or GRAPHQL_DEBUG is defined, return the tokens
300+ * otherwise do not return them.
301+ */
302+ if ( is_ssl () || defined ( 'GRAPHQL_DEBUG ' ) && true !== GRAPHQL_DEBUG ) {
303+ $ should_return_tokens = true ;
304+ }
305+
306+ if ( ! $ should_return_tokens ) {
307+ return $ headers ;
308+ }
309+
296310 /**
297311 * If there's a Refresh-Authorization token in the request headers, validate it
298312 */
@@ -344,6 +358,20 @@ public static function add_tokens_to_graphql_response_headers( $headers ) {
344358 */
345359 public static function add_auth_headers_to_rest_response ( \WP_HTTP_Response $ response , $ handler , $ request ) {
346360
361+ $ should_return_tokens = false ;
362+
363+ /**
364+ * If the request _is_ SSL, or GRAPHQL_DEBUG is defined, return the tokens
365+ * otherwise do not return them.
366+ */
367+ if ( is_ssl () || defined ( 'GRAPHQL_DEBUG ' ) && true !== GRAPHQL_DEBUG ) {
368+ $ should_return_tokens = true ;
369+ }
370+
371+ if ( ! $ should_return_tokens ) {
372+ return $ response ;
373+ }
374+
347375 /**
348376 * Note: The Access-Control-Expose-Headers aren't directly filterable
349377 * for REST API responses, so this overrides them altogether.
You can’t perform that action at this time.
0 commit comments