<s> """<STR_LIT>""" <EOL> from . base import IAccessBackend <EOL> class RemoteAccessBackend ( IAccessBackend ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , request = None , settings = None , server = None , auth = None , <EOL> ** kwargs ) : <EOL> super ( RemoteAccessBackend , self ) . __init__ ( request , ** kwargs ) <EOL> self . _settings = settings <EOL> self . server = server <EOL> self . auth = auth <EOL> @ classmethod <EOL> def configure ( cls , settings ) : <EOL> kwargs = super ( RemoteAccessBackend , cls ) . configure ( settings ) <EOL> kwargs [ '<STR_LIT>' ] = settings <EOL> kwargs [ '<STR_LIT>' ] = settings [ '<STR_LIT>' ] <EOL> auth = None <EOL> user = settings . get ( '<STR_LIT>' ) <EOL> if user is not None : <EOL> password = settings . get ( '<STR_LIT>' ) <EOL> auth = ( user , password ) <EOL> kwargs [ '<STR_LIT>' ] = auth <EOL> return kwargs <EOL> def _req ( self , uri , params = None ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> import requests <EOL> except ImportError : <EOL> raise ImportError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> response = requests . get ( self . server + uri , params = params , <EOL> auth = self . auth ) <EOL> response . raise_for_status ( ) <EOL> return response . json ( ) <EOL> def verify_user ( self , username , password ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> params = { '<STR_LIT:username>' : username , '<STR_LIT:password>' : password } <EOL> return self . _req ( uri , params ) <EOL> def _get_password_hash ( self , username ) : <EOL> pass <EOL> def groups ( self , username = None ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> params = { } <EOL> if username is not None : <EOL> params [ '<STR_LIT:username>' ] = username <EOL> return self . _req ( uri , params ) <EOL> def group_members ( self , group ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> params = { '<STR_LIT>' : group } <EOL> return self . _req ( uri , params ) <EOL> def is_admin ( self , username ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> params = { '<STR_LIT:username>' : username } <EOL> return self . _req ( uri , params ) <EOL> def group_permissions ( self , package , group = None ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> params = { '<STR_LIT>' : package } <EOL> if group is not None : <EOL> params [ '<STR_LIT>' ] = group <EOL> return self . _req ( uri , params ) <EOL> def user_permissions ( self , package , username = None ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> params = { '<STR_LIT>' : package } <EOL> if username is not None : <EOL> params [ '<STR_LIT:username>' ] = username <EOL> return self . _req ( uri , params ) <EOL> def user_package_permissions ( self , username ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> params = { '<STR_LIT:username>' : username } <EOL> return self . _req ( uri , params ) <EOL> def group_package_permissions ( self , group ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> params = { '<STR_LIT>' : group } <EOL> return self . _req ( uri , params ) <EOL> def user_data ( self , username = None ) : <EOL> uri = self . _settings . get ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> params = None <EOL> if username is not None : <EOL> params = { '<STR_LIT:username>' : username } <EOL> return self . _req ( uri , params ) </s>
