Skip to content

Commit

Permalink
added some basic authorisation header to whitelist some users
Browse files Browse the repository at this point in the history
  • Loading branch information
Karolis Rusenas committed Aug 18, 2015
1 parent d62118e commit 72fe39e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,29 @@ def get(self):
self.redirect(self.get_argument("next", "/"))


def allowed():
def decorator(func):
def decorated(self, *args, **kwargs):
user = self.get_current_user()

# User is refused
if user is None:
raise Exception('Cannot proceed role check: user not found')

if user.decode("utf-8") not in self.settings['sFwhitelist']:
self.set_status(403)
return self.render('500.html',
code=403,
error="Not authorized")
# self.set_status(403, reason='Not authorized. Contact administrator.')
# self._transforms = []
# self.finish()
# return None

return func(self, *args, **kwargs)
return decorated
return decorator

EXECUTOR = ThreadPoolExecutor(max_workers=100)

def unblock(f):
Expand Down

0 comments on commit 72fe39e

Please sign in to comment.