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

Better middleware handling #439

Open
fergusean opened this issue Apr 15, 2023 · 0 comments
Open

Better middleware handling #439

fergusean opened this issue Apr 15, 2023 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@fergusean
Copy link
Contributor

For the sake of convenience across multiple (sometimes layered) authorization scenarios (meaning, some controllers require standard HTTP auth, but some controllers are explicitly for use by an app that has to present certain identity headers), I use middleware for auth rather than the onAuth HTTP hook. I’m running a patched version of onRoute to disable the middleware timeouts, since a timeout in the middleware would enable a client to hit an endpoint controller they may not be authorized to hit. While I agree middleware should be fast, there may be database connectivity issues, etc. At the very least, I would expect the application would throw if the middleware timed out, not fall through to the controller.

Also, if middleware throws an error, the client is sent a 404, rather than a 500. I would expect that the proper behavior is to handle errors inheriting from HttpError the same as if they were thrown from a controller, and throw anything else as a 500.

@marcj marcj added the enhancement New feature or request label May 8, 2023
@marcj marcj added this to the Beta milestone May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants