Add scope ordinality and translations. Process oauth tokens and limit scopes accordingly.
This commit is contained in:
parent
25ceb90fc6
commit
e74eb3ee87
8 changed files with 137 additions and 31 deletions
|
@ -23,3 +23,12 @@ CREATE_REPO = {
|
|||
}
|
||||
|
||||
ALL_SCOPES = {scope['scope']:scope for scope in (READ_REPO, WRITE_REPO, ADMIN_REPO, CREATE_REPO)}
|
||||
|
||||
|
||||
def scopes_from_scope_string(scopes):
|
||||
return {ALL_SCOPES.get(scope, {}).get('scope', None) for scope in scopes.split(',')}
|
||||
|
||||
|
||||
def validate_scope_string(scopes):
|
||||
decoded = scopes_from_scope_string(scopes)
|
||||
return None not in decoded and len(decoded) > 0
|
||||
|
|
Reference in a new issue