def allowed_from_settings(settings, principals):
 perms_settings = {k: aslist(v) for (k, v) in settings.items() if k.endswith('_principals')}
 from_settings = {}
 for (key, allowed_principals) in perms_settings.items():
  (resource_name, permission, _) = key.split('_')
  if (resource_name not in PERMISSIONS_INHERITANCE_TREE.keys()):
   continue
  if (not bool((set(principals) & set(allowed_principals)))):
   continue
  if (permission == 'create'):
   permission = ('%s:%s' % (resource_name, permission))
   resource_name = {'bucket': '', 'collection': 'bucket', 'group': 'bucket', 'record': 'collection'}[resource_name]
  from_settings.setdefault(resource_name, set()).add(permission)
 return from_settings

def allowed_from_settings ( settings , principals ) : perms_settings = { k : aslist ( v ) for ( k , v ) in settings . items ( ) if k . endswith ( '_principals' ) } from_settings = { } for ( key , allowed_principals ) in perms_settings . items ( ) : ( resource_name , permission , _ ) = key . split ( '_' ) if ( resource_name not in PERMISSIONS_INHERITANCE_TREE . keys ( ) ) : continue if ( not bool ( ( set ( principals ) & set ( allowed_principals ) ) ) ) : continue if ( permission == 'create' ) : permission = ( '%s:%s' % ( resource_name , permission ) ) resource_name = { 'bucket' : '' , 'collection' : 'bucket' , 'group' : 'bucket' , 'record' : 'collection' } [ resource_name ] from_settings . setdefault ( resource_name , set ( ) ) . add ( permission ) return from_settings
returns every permissions allowed from settings for the current user .