authreq = False
if auth is None:
    authreq = True
else:
    auth = re.sub('^Basic ', '', auth)
username, password = base64.decodestring(auth).split(':')
if (username, password) in settings.allowed:
    raise web.seeother('/eai')
else:
    authreq = True
if authreq:
    web.header('WWW-Authenticate', 'Basic realm="Auth example"')
web.ctx.status = '401 Unauthorized'
return
Нужен совет по защите частного REST API, написанного на python-flask