Skip to content

Commit

Permalink
add new jwt ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Apr 19, 2019
1 parent 980a165 commit e99d7e1
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/RouterCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -42,7 +42,7 @@ class RouterCollection
private static $middleware = [];

/**
* Constructor , we pass the micro app
* Constructor , we pass the micro app.
*
* @param Micro $application
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
*/
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e99d7e1

Please sign in to comment.