Make the scopes dynamic based on app config.
This commit is contained in:
parent
053ceb6220
commit
f5ee7a6697
3 changed files with 14 additions and 7 deletions
|
@ -69,8 +69,8 @@ SUPERUSER = Scope(scope='super:user',
|
|||
'absolute trust in the requesting application before granting this '
|
||||
'permission.'))
|
||||
|
||||
ALL_SCOPES = {scope.scope:scope for scope in (READ_REPO, WRITE_REPO, ADMIN_REPO, CREATE_REPO,
|
||||
READ_USER, ORG_ADMIN)}
|
||||
ALL_SCOPES = {scope.scope: scope for scope in (READ_REPO, WRITE_REPO, ADMIN_REPO, CREATE_REPO,
|
||||
READ_USER, ORG_ADMIN, SUPERUSER)}
|
||||
|
||||
IMPLIED_SCOPES = {
|
||||
ADMIN_REPO: {ADMIN_REPO, WRITE_REPO, READ_REPO},
|
||||
|
@ -79,12 +79,18 @@ IMPLIED_SCOPES = {
|
|||
CREATE_REPO: {CREATE_REPO},
|
||||
READ_USER: {READ_USER},
|
||||
ORG_ADMIN: {ORG_ADMIN},
|
||||
SUPERUSER: {SUPERUSER},
|
||||
None: set(),
|
||||
}
|
||||
|
||||
if features.SUPER_USERS:
|
||||
ALL_SCOPES[SUPERUSER.scope] = SUPERUSER
|
||||
IMPLIED_SCOPES[SUPERUSER] = {SUPERUSER}
|
||||
|
||||
def app_scopes(app_config):
|
||||
if not app_config.get('FEATURE_SUPER_USERS', False):
|
||||
scopes_from_config = dict(ALL_SCOPES)
|
||||
del scopes_from_config[SUPERUSER.scope]
|
||||
return scopes_from_config
|
||||
return ALL_SCOPES
|
||||
|
||||
|
||||
def scopes_from_scope_string(scopes):
|
||||
if not scopes:
|
||||
|
|
Reference in a new issue