Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Restrict sensitive URL's with a secret key

Signed-off-by: Luke Closs <gravatar@5thplane.com>
  • Loading branch information...
commit de345c0a92b7bbd45db57063cc127fa29317cf1a 1 parent 49621a6
@safetydank safetydank authored lukec committed
Showing with 15 additions and 0 deletions.
  1. +15 −0 sensor/www/sensor.py
View
15 sensor/www/sensor.py
@@ -46,6 +46,20 @@
r'.*', 'Static',
)
+# restricted URL's require this key to be passed in as a GET or
+# POST param.
+SECRET_KEY='7787855982'
+
+# use the @restricted decorator to protect sensitive URLs
+def restricted(view):
+ def _decorator(*args, **kw):
+ params = web.input(key=None)
+ if params.key != SECRET_KEY:
+ return 'This URL is restricted to VHS members: info@vancouver.hackspace.ca'
+
+ return view(*args, **kw)
+ return _decorator
+
app = web.application(urls, globals())
def serial_query(query):
@@ -150,6 +164,7 @@ def GET(self):
""" % DOC
class Buzz:
+ @restricted
def GET(self):
return serial_query('buzz');
Please sign in to comment.
Something went wrong with that request. Please try again.