-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
HTTP Auth Middleware #363
Comments
I'm interested by this as well. |
Such a module has to be carefully planned ahead. Many of them end up inflexible or difficuly to use (even in big frameworks). I'm still not sure to what extend local middleware should be used here. Its a good fit for wrapping a small group of handlers. How to apply things selectively on big handler groups?
What path to take has to be decided ahead, so all middleware stays uniform and all further development and changes conform to it.
// | - list special middlware only for that bp
// | now you dont have to call CROW_MIDDLEWARES() on each route
// |
Blueprint<AdminGuard> adminbp(prefix);
// ...
app.register_blueprint(adminbp); This seems quite convenient to me. But now you're forced to use blueprints everywhere. The other question is what should be supported. The more features you support, the harder it is to make them flexible. I'll think about it once again and write back shortly. What's your vision like? |
In my experience using Flask I just added
I think CORS was a special case in that you needed those headers regardless of which route you took, the difference between routes was which headers would be sent. So it made sense to sort out prefixes inside the middleware rather than before it's even called.
In my opinion this would be the best and most consistent option.
This is somewhat mitigated by the fact that (at least for production applications) you're supposed to use blueprints everywhere, they're designed to segment the application with as little hassle as possible on the developer's side. It would be ideal if local middleware could also be applied to blueprints, rather than having a third kind of middleware. The idea generally for Crow is somewhat driven from python Flask, in that it's easy to use and very easy to get started with. But with the addition of keeping the inner workings of HTTP accessible for anyone who wants a feature that hasn't been implemented yet. I hope this has explained my general stance on the issue. And I'm sorry I didn't respond right away (I tend to take weekends off in order to keep some semblance of work-life balance). |
Great 👍🏻 I'm in for Blueprints as well. |
Lets close this issue in favour of #376 (comment) |
@dranikpg I disagree on the idea that an Auth middleware isn't needed, it might be useful to have some examples on how to implement things like token storage or JWT creation, but handling those (whether it's functions to create tokens that people can assign or authenticating those tokens in a route) should be done through a simple interface. I think we need to provide some framework to guide people building their auth system (without them needing to access headers directly or splitting strings etc...) |
Since #327 was merged, adding a middleware for HTTP authentication should be possible and would be a better solution than the current guide.
The text was updated successfully, but these errors were encountered: