Repository navigation
API design for tornado guard #2
joegasewicz
started this conversation in
Ideas
Replies: 1 comment 4 replies
|
Thanks for this Joe! I checked the issues you shared. So the mixin pattern is the way to go: class GuardMixin:
async def prepare(self):
# security pipeline runs here
await super().prepare()
def on_finish(self):
# response processing, metrics, logging
super().on_finish()Users would then compose it into their handlers: class MyHandler(GuardMixin, tornado.web.RequestHandler):
def get(self):
self.write({"status": "ok"})This is consistent with how your tornado-auth-sessions mixin works, and with the example user ploxiln gave. One thing to figure out: how to pass SecurityConfig to the mixin. Options I see:
Thoughts? |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The below issues will give some context on why tornado doesn't have a middleware or extension plugin api:
This is a quote from one of the main maintainers of tornado (@ploxiln):
https://github.com/bdarnell/tornado_http2
https://www.tornadoweb.org/en/stable/routing.html
https://github.com/siddhantgoel/streaming-form-data/blob/master/examples/tornado/stream_request_body.py
You can also use the mixin pattern, just pass it any subclasses you are extending e.g
All reactions