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
How do you allow only some get routes to have auth #230
Comments
Something like this should work. $app->add(new Tuupola\Middleware\JwtAuthentication([
"rules" => [
new Tuupola\Middleware\JwtAuthentication\RequestPathRule([
"path" => ["/projectData"],
"ignore" => []
]),
new Tuupola\Middleware\JwtAuthentication\RequestMethodRule([
"ignore" => ["OPTIONS", "GET"]
])
]
])) |
This worked perfectly! Although a quick follow-up question. How would I allow some GET routes to have auth on them? I tried to put the route in the path, like so: $app->add(new Tuupola\Middleware\JwtAuthentication([
"rules" => [
new Tuupola\Middleware\JwtAuthentication\RequestPathRule([
"path" => ["/projectData", "/user/getUserInfo"],
"ignore" => []
]),
new Tuupola\Middleware\JwtAuthentication\RequestMethodRule([
"ignore" => ["OPTIONS", "GET"]
])
]
])) This however didn't work and it didn't require auth for the get route of |
In your config you are ignoring all $app->add(new JwtAuthentication([
"path" => ["/api", "/admin"]
])); Now any path starting with /* Add to single route */
$app->get("/", function () { ... })->add(new JwtAuthentication());
/* Add to route group */
$app->group("/", function () { ... })->add(new JwtAuthentication()); |
I'm making an API where some data is publicly available for my site and some need auth. I know I can add this,
This allows all GET methods to have no auth on them. so is there a way to specify
/projectData
as a GET route that has no auth but/projetData
as a POST, PUT, PATCH, DELETE routes have auth on themThe text was updated successfully, but these errors were encountered: