Modification for static handler

Johan Hartzenberg <[email protected]> Mon, 21 Nov 2016 03:24:04 -0800 (PST)
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
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 cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.