Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify TTL per path? #24

Open
Tsaukpaetra opened this issue Oct 25, 2022 · 2 comments
Open

Ability to specify TTL per path? #24

Tsaukpaetra opened this issue Oct 25, 2022 · 2 comments

Comments

@Tsaukpaetra
Copy link

I was pondering on how to make this middleware apply the ttl parameter differently depending on which path was provided.
Is the best way to do this by leaving the library's ttl option null and instead adding a before callable which re-decodes the token to extract the timestamp?

I was thinking if it would be feasible to run through an array of callables if the ttl option was specified like that in a similar manner to the rules, but I'm not sure how effective that would be either.

@tuupola
Copy link
Owner

tuupola commented Oct 25, 2022

Some frameworks allow you to attach middleware to specific routes or routegroups. So you could create two (or more) instances of the middleware with different ttl settings and then attachs these to different routes.

With Slim it would be something like:

$mw1 = new Tuupola\Middleware\BrancaAuthentication([
    "ttl" => 60, /* 60 seconds */
]);

$mw2 = new Tuupola\Middleware\BrancaAuthentication([
    "ttl" => 3600, /* 60 minutes */
]);

...

$app->get("/foo", function () { ... })->add($mw1);
$app->get("/bar", function () { ... })->add($mw2);

@Tsaukpaetra
Copy link
Author

Huh. Sounds like a plan thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants