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

Incoherent behaviour of publicEndpoints option in authenticationMiddleware #220

Open
bzums opened this issue Jun 7, 2018 · 4 comments
Open
Labels

Comments

@bzums
Copy link
Collaborator

bzums commented Jun 7, 2018

if (publicEndpoints && publicEndpoints.some(pattern => originalUrl.startsWith(pattern))) {

When a public endpoint test is added, than all endpoints starting with test (e.g. test-another) will also be public which is not expected.

We should discuss how to handle subressources like test/another=> should they also be public by default or not?

@bzums bzums added the bug label Jun 7, 2018
@bzums bzums changed the title incoherent behaviour of publicEndpoints option in authenticationMiddleware Incoherent behaviour of publicEndpoints option in authenticationMiddleware Jun 7, 2018
@Retro64
Copy link
Collaborator

Retro64 commented Jun 12, 2018

It makes no sense to inherit the secure level of sub resources - at least if the resource itself is public (e.g. if the sub resource containing confidential data). Therefore a predicate like equals makes more sense. On the other hand, equals is not feasible, as /res/${id}/subres/${subid} cannot be matched via equal directly.

@ValentinFunk
Copy link
Contributor

It would be possible to use req.route to get the route of the request. So you could do publicEndpoints = [ '/res/${id}/subres/${subid}].

The only issue is that if you mount express sub apps you would probably need to create middleware instances for each so that the route is given correctly.

@bzums
Copy link
Collaborator Author

bzums commented Oct 4, 2018

Indeed I think inheriting is not a good idea. To really solve the issue I guess we need to support passing a regexp to `publicEndpoints?!

@ValentinFunk
Copy link
Contributor

Maybe just a callback where users can define their own logic? So everyone can use whatever they prefer. I feel that honestly users should just apply middleware only where needed, so that you wouldn't need to use this at all. If this is not possible they could then do it in whatever way they like (regex, route parsing, perhaps even header based if there is a possiblity of an auth proxy in front).

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

No branches or pull requests

3 participants