From 1016641f8d8361344eee88d58d05d847e6548807 Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Mon, 27 Mar 2017 10:55:18 -0400 Subject: [PATCH] refactor jwt context building --- util/security/registry_jwt.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/util/security/registry_jwt.py b/util/security/registry_jwt.py index b8efc364c..373e990a7 100644 --- a/util/security/registry_jwt.py +++ b/util/security/registry_jwt.py @@ -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)