From e99d7e1408066c4b30450455c32adb810ce41e49 Mon Sep 17 00:00:00 2001 From: mctekk Date: Thu, 18 Apr 2019 23:18:03 -0400 Subject: [PATCH] add new jwt ignore --- src/RouterCollection.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/RouterCollection.php b/src/RouterCollection.php index c6ce900..e8941d2 100755 --- a/src/RouterCollection.php +++ b/src/RouterCollection.php @@ -7,7 +7,7 @@ use \Phalcon\Mvc\Micro\Collection as MicroCollection; /** - * Router collection for Micro Phalcon API, insted of having to do + * Router collection for Micro Phalcon API, insted of having to do. * * Phalcon Way * $index = new MicroCollection(); @@ -42,7 +42,7 @@ class RouterCollection private static $middleware = []; /** - * Constructor , we pass the micro app + * Constructor , we pass the micro app. * * @param Micro $application */ @@ -52,7 +52,7 @@ public function __construct(Micro $application) } /** - * If the router is user a prefix + * If the router is user a prefix. * * @param string $prefix */ @@ -62,7 +62,7 @@ public function setPrefix(string $prefix): void } /** - * Mount the collection to the micro app router + * Mount the collection to the micro app router. * * @return void */ @@ -90,7 +90,7 @@ public function mount(): void } /** - * Add the call function to the collection array + * Add the call function to the collection array. * * @param string $method * @param string $pattern @@ -120,7 +120,7 @@ private function call(string $method, string $pattern, string $className, string } /** - * Set routers options JWT + * Set routers options JWT. * * @todo add Middleware that the router will call * @param array $route @@ -133,13 +133,14 @@ private function setOptions(array $route, array $options): void //only add if we want to ignore this url if (!$options['options']['jwt']) { self::$hasJwtOptionsSetup = true; - self::$jwt[] = 'regex:^' . $this->prefix . $route['pattern'] . '$:' . strtoupper($route['method']); + //we group them by method and hash the pattern to make it a faster lookup + self::$jwt[strtoupper($route['method'])][md5($this->prefix . $route['pattern'])] = $this->prefix . $route['pattern']; } } } /** - * Get the ignore JWT url + * Get the ignore JWT url. * * @return array */ @@ -154,7 +155,7 @@ public static function getJwtIgnoreRoutes(): array } /** - * Insted of using magic we define each method function + * Insted of using magic we define each method function. * * @param string $pattern * @param array $param @@ -166,7 +167,7 @@ public function get(string $pattern, array $param): void } /** - * Insted of using magic we define each method function + * Insted of using magic we define each method function. * * @param string $pattern * @param array $param @@ -178,7 +179,7 @@ public function put(string $pattern, array $param) : void } /** - * Insted of using magic we define each method function + * Insted of using magic we define each method function. * * @param string $pattern * @param array $param @@ -190,7 +191,7 @@ public function post(string $pattern, array $param) : void } /** - * Insted of using magic we define each method function + * Insted of using magic we define each method function. * * @param string $pattern * @param array $param @@ -202,7 +203,7 @@ public function delete(string $pattern, array $param) : void } /** - * Insted of using magic we define each method function + * Insted of using magic we define each method function. * * @param string $pattern * @param array $param @@ -214,7 +215,7 @@ public function patch(string $pattern, array $param) : void } /** - * Insted of using magic we define each method function + * Insted of using magic we define each method function. * * @param string $pattern * @param array $param @@ -226,7 +227,7 @@ public function options(string $pattern, array $param) : void } /** - * Instead of using magic we define each method function + * Instead of using magic we define each method function. * * @param string $pattern * @param array $param