Skip to content

Commit 004b661

Browse files
committed
feat: Adds filter for auth header name
1 parent 6f4c18a commit 004b661

File tree

13 files changed

+608
-313
lines changed

13 files changed

+608
-313
lines changed

src/Auth.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,11 +623,16 @@ public static function validate_token( $token = null, $refresh = false ) {
623623
*/
624624
public static function get_auth_header() {
625625

626+
/**
627+
* Filter target HTTP Header.
628+
*/
629+
$header_name = apply_filters( 'graphql_jwt_auth_header_name', 'HTTP_AUTHORIZATION' );
630+
626631
/**
627632
* Looking for the HTTP_AUTHORIZATION header, if not present just
628633
* return the user.
629634
*/
630-
$auth_header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : false;
635+
$auth_header = isset( $_SERVER[ $header_name] ) ? $_SERVER[ $header_name ] : false;
631636

632637
/**
633638
* Double check for different auth header string (server dependent)

vendor/composer/ClassLoader.php

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@
3737
*
3838
* @author Fabien Potencier <[email protected]>
3939
* @author Jordi Boggiano <[email protected]>
40-
* @see http://www.php-fig.org/psr/psr-0/
41-
* @see http://www.php-fig.org/psr/psr-4/
40+
* @see https://www.php-fig.org/psr/psr-0/
41+
* @see https://www.php-fig.org/psr/psr-4/
4242
*/
4343
class ClassLoader
4444
{
45+
private $vendorDir;
46+
4547
// PSR-4
4648
private $prefixLengthsPsr4 = array();
4749
private $prefixDirsPsr4 = array();
@@ -57,10 +59,17 @@ class ClassLoader
5759
private $missingClasses = array();
5860
private $apcuPrefix;
5961

62+
private static $registeredLoaders = array();
63+
64+
public function __construct($vendorDir = null)
65+
{
66+
$this->vendorDir = $vendorDir;
67+
}
68+
6069
public function getPrefixes()
6170
{
6271
if (!empty($this->prefixesPsr0)) {
63-
return call_user_func_array('array_merge', $this->prefixesPsr0);
72+
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
6473
}
6574

6675
return array();
@@ -300,6 +309,17 @@ public function getApcuPrefix()
300309
public function register($prepend = false)
301310
{
302311
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
312+
313+
if (null === $this->vendorDir) {
314+
return;
315+
}
316+
317+
if ($prepend) {
318+
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
319+
} else {
320+
unset(self::$registeredLoaders[$this->vendorDir]);
321+
self::$registeredLoaders[$this->vendorDir] = $this;
322+
}
303323
}
304324

305325
/**
@@ -308,13 +328,17 @@ public function register($prepend = false)
308328
public function unregister()
309329
{
310330
spl_autoload_unregister(array($this, 'loadClass'));
331+
332+
if (null !== $this->vendorDir) {
333+
unset(self::$registeredLoaders[$this->vendorDir]);
334+
}
311335
}
312336

313337
/**
314338
* Loads the given class or interface.
315339
*
316340
* @param string $class The name of the class
317-
* @return bool|null True if loaded, null otherwise
341+
* @return true|null True if loaded, null otherwise
318342
*/
319343
public function loadClass($class)
320344
{
@@ -323,6 +347,8 @@ public function loadClass($class)
323347

324348
return true;
325349
}
350+
351+
return null;
326352
}
327353

328354
/**
@@ -367,6 +393,16 @@ public function findFile($class)
367393
return $file;
368394
}
369395

396+
/**
397+
* Returns the currently registered loaders indexed by their corresponding vendor directories.
398+
*
399+
* @return self[]
400+
*/
401+
public static function getRegisteredLoaders()
402+
{
403+
return self::$registeredLoaders;
404+
}
405+
370406
private function findFileWithExtension($class, $ext)
371407
{
372408
// PSR-4 lookup

0 commit comments

Comments
 (0)