We can't count on auth tokens being sent anymore, so we set the namespace and repository for the session when the original put on the repo is made.
This commit is contained in:
parent
8917812efa
commit
61618c7eab
2 changed files with 8 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
|
||||
from functools import wraps
|
||||
from flask import request, make_response, _request_ctx_stack, abort, session
|
||||
from flask import request, _request_ctx_stack, abort, session
|
||||
from flask.ext.principal import identity_changed, Identity
|
||||
from base64 import b64decode
|
||||
|
||||
|
@ -106,9 +106,6 @@ def process_token(auth):
|
|||
token_vals['signature'])
|
||||
abort(401)
|
||||
|
||||
session['repository'] = token_data.repository.name
|
||||
session['namespace'] = token_data.repository.namespace
|
||||
|
||||
logger.debug('Successfully validated token: %s' % token_data.code)
|
||||
ctx = _request_ctx_stack.top
|
||||
ctx.validated_token = token_data
|
||||
|
@ -136,7 +133,8 @@ def extract_namespace_repo_from_session(f):
|
|||
@wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
if 'namespace' not in session or 'repository' not in session:
|
||||
logger.debug('Unable to load namespace or repository from session.')
|
||||
logger.error('Unable to load namespace or repository from session: %s' %
|
||||
session)
|
||||
abort(400)
|
||||
|
||||
return f(session['namespace'], session['repository'], *args, **kwargs)
|
||||
|
|
Reference in a new issue