Modification for static handler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Modification for static handler

Johan Hartzenberg
In my system I have a routedispatcher handler mounted at /api and I have a static handler mounted at /static

This works OK but I have an idea of how to add authentication to the static aspect.  I use JWTs for access to most handlers in /api already.

I would like the static files under /static/pub to be served as is - These are "public".

For entries under /static/{username}/* I want the handler to check that a valid JWT is included in a Bearer Authorization header with a sub matching the "username" portion of the path...

For the static file serving I currently use:
static_dir = os.path.abspath(os.path.dirname(__file__))
static_files_conf = {'/': {'tools.staticdir.root': static_dir,
'tools.staticdir.on': True,
'tools.staticdir.dir': 'static',
'tools.expires.on': True,
'tools.expires.secs': 15552000 # six months. Updated files will be given a new URI!
}}
cherrypy.tree.mount(None, '/static', config=static_files_conf)


Thank you!

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.