refactor jwt context building

This commit is contained in:
Evan Cordell 2017-03-27 10:55:18 -04:00
parent 4c94d2c760
commit 1016641f8d

View file

@ -110,35 +110,35 @@ def build_context_and_subject(user=None, token=None, oauthtoken=None, tuf_root=N
if not tuf_root:
tuf_root = QUAY_TUF_ROOT
context = {
CLAIM_TUF_ROOT: tuf_root
}
if oauthtoken:
context = {
context.update({
'kind': 'oauth',
'user': user.username,
'oauth': oauthtoken.uuid,
CLAIM_TUF_ROOT: tuf_root,
}
})
return (context, user.username)
if user:
context = {
context.update({
'kind': 'user',
'user': user.username,
CLAIM_TUF_ROOT: tuf_root,
}
})
return (context, user.username)
if token:
context = {
context.update({
'kind': 'token',
'token': token.code,
CLAIM_TUF_ROOT: tuf_root,
}
})
return (context, None)
context = {
context.update({
'kind': 'anonymous',
CLAIM_TUF_ROOT: tuf_root,
}
})
return (context, ANONYMOUS_SUB)