Add scope ordinality and translations. Process oauth tokens and limit scopes accordingly.

This commit is contained in:
jakedt 2014-03-12 16:31:37 -04:00
parent 25ceb90fc6
commit e74eb3ee87
8 changed files with 137 additions and 31 deletions

View file

@ -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