Skip to content

Commit

Permalink
Additional logging around security management.
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgregor committed Jan 5, 2021
1 parent 7e4430a commit 494ef44
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/ext/contentment.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,22 @@ def prepare(self, context):
context.theme = load('web.theme.bootstrap.base:page')

if 'SECRET' in os.environ and 'uid' in context.request.cookies:
log.info("Authenticated request.")
s = TimestampSigner(os.environ['SECRET'])
try:
uc = user_cookie.bind(context.request)
token = uc.get_value()
token = s.unsign(token, max_age=60*60*24).decode('ascii')
except:
except Exception as e:
log.exception("Error de-serializing UID: " + str(e), exc_info=True)
context.uid = None
if __debug__: raise
else:
context.uid = token.partition('-')[2]
else:
context.uid = None

log.info("Prepared context.", extra=dict(domain=[dom, context.domain], lang=context.lang, root=repr(context.croot), theme=repr(context.theme)))
log.info("Prepared context.", extra=dict(domain=[dom, context.domain], lang=context.lang, root=repr(context.croot), theme=repr(context.theme), uid=context.uid))

def render_json_response(self, context, result):
import json
Expand Down

0 comments on commit 494ef44

Please sign in to comment.