refactor jwt context building
This commit is contained in:
parent
4c94d2c760
commit
1016641f8d
1 changed files with 12 additions and 12 deletions
|
@ -110,35 +110,35 @@ def build_context_and_subject(user=None, token=None, oauthtoken=None, tuf_root=N
|
||||||
if not tuf_root:
|
if not tuf_root:
|
||||||
tuf_root = QUAY_TUF_ROOT
|
tuf_root = QUAY_TUF_ROOT
|
||||||
|
|
||||||
|
context = {
|
||||||
|
CLAIM_TUF_ROOT: tuf_root
|
||||||
|
}
|
||||||
|
|
||||||
if oauthtoken:
|
if oauthtoken:
|
||||||
context = {
|
context.update({
|
||||||
'kind': 'oauth',
|
'kind': 'oauth',
|
||||||
'user': user.username,
|
'user': user.username,
|
||||||
'oauth': oauthtoken.uuid,
|
'oauth': oauthtoken.uuid,
|
||||||
CLAIM_TUF_ROOT: tuf_root,
|
})
|
||||||
}
|
|
||||||
return (context, user.username)
|
return (context, user.username)
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
context = {
|
context.update({
|
||||||
'kind': 'user',
|
'kind': 'user',
|
||||||
'user': user.username,
|
'user': user.username,
|
||||||
CLAIM_TUF_ROOT: tuf_root,
|
})
|
||||||
}
|
|
||||||
return (context, user.username)
|
return (context, user.username)
|
||||||
|
|
||||||
if token:
|
if token:
|
||||||
context = {
|
context.update({
|
||||||
'kind': 'token',
|
'kind': 'token',
|
||||||
'token': token.code,
|
'token': token.code,
|
||||||
CLAIM_TUF_ROOT: tuf_root,
|
})
|
||||||
}
|
|
||||||
return (context, None)
|
return (context, None)
|
||||||
|
|
||||||
context = {
|
context.update({
|
||||||
'kind': 'anonymous',
|
'kind': 'anonymous',
|
||||||
CLAIM_TUF_ROOT: tuf_root,
|
})
|
||||||
}
|
|
||||||
return (context, ANONYMOUS_SUB)
|
return (context, ANONYMOUS_SUB)
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue