original_docstring: 
          Check the username and password/keypair info for validity. If valid,
          set a 'credentials' attribute consisting of the appropriate Pygit2
          credentials object. Return False if a required auth param is not
          present. Return True if the required auth parameters are present (or
          auth is not configured), otherwise failhard if there is a problem with
          authenticaion.
          
docstring: Check the username and password/keypair info for validity. If valid,
  set a 'credentials' attribute consisting of the appropriate Pygit2
  credentials object. Return False if a required auth param is not
  present. Return True if the required auth parameters are present (or
  auth is not configured), otherwise failhard if there is a problem with
  authenticaion.
docstring_tokens: Check the username and password / keypair info for validity . If valid set a ' credentials ' attribute consisting of the appropriate Pygit2 credentials object . Return False if a required auth param is not present . Return True if the required auth parameters are present ( or auth is not configured ) otherwise failhard if there is a problem with authenticaion .
code: def verify_auth(self):
          '''
          Check the username and password/keypair info for validity. If valid,
          set a 'credentials' attribute consisting of the appropriate Pygit2
          credentials object. Return False if a required auth param is not
          present. Return True if the required auth parameters are present (or
          auth is not configured), otherwise failhard if there is a problem with
          authenticaion.
          '''
          self.credentials = None
  
          if os.path.isabs(self.url):
              # If the URL is an absolute file path, there is no authentication.
              return True
          elif not any(getattr(self, x, None) for x in AUTH_PARAMS):
              # Auth information not configured for this remote
              return True
  
          def _incomplete_auth(missing):
              '''
              Helper function to log errors about missing auth parameters
              '''
              log.critical(
                  'Incomplete authentication information for %s remote '
                  '\'%s\'. Missing parameters: %s',
                  self.role, self.id, ', '.join(missing)
              )
              failhard(self.role)
  
          def _key_does_not_exist(key_type, path):
              '''
              Helper function to log errors about missing key file
              '''
              log.critical(
                  'SSH %s (%s) for %s remote \'%s\' could not be found, path '
                  'may be incorrect. Note that it may be necessary to clear '
                  'git_pillar locks to proceed once this is resolved and the '
                  'master has been started back up. A warning will be logged '
                  'if this is the case, with instructions.',
                  key_type, path, self.role, self.id
              )
              failhard(self.role)
  
          transport, _, address = self.url.partition('://')
          if not address:
              # Assume scp-like SSH syntax (user@domain.tld:relative/path.git)
              transport = 'ssh'
              address = self.url
  
          transport = transport.lower()
  
          if transport in ('git', 'file'):
              # These transports do not use auth
              return True
  
          elif 'ssh' in transport:
              required_params = ('pubkey', 'privkey')
              user = address.split('@')[0]
              if user == address:
                  # No '@' sign == no user. This is a problem.
                  log.critical(
                      'Keypair specified for {0} remote \'{1}\', but remote URL '
                      'is missing a username'.format(self.role, self.id)
                  )
                  failhard(self.role)
  
              self.user = user
              if all(bool(getattr(self, x, None)) for x in required_params):
                  keypair_params = [getattr(self, x, None) for x in
                                    ('user', 'pubkey', 'privkey', 'passphrase')]
                  # Check pubkey and privkey to make sure file exists
                  for idx, key_type in ((1, 'pubkey'), (2, 'privkey')):
                      key_path = keypair_params[idx]
                      if key_path is not None:
                          try:
                              if not os.path.isfile(key_path):
                                  _key_does_not_exist(key_type, key_path)
                          except TypeError:
                              _key_does_not_exist(key_type, key_path)
                  self.credentials = pygit2.Keypair(*keypair_params)
                  return True
              else:
                  missing_auth = [x for x in required_params
                                  if not bool(getattr(self, x, None))]
                  _incomplete_auth(missing_auth)
  
          elif 'http' in transport:
              required_params = ('user', 'password')
              password_ok = all(
                  bool(getattr(self, x, None)) for x in required_params
              )
              no_password_auth = not any(
                  bool(getattr(self, x, None)) for x in required_params
              )
              if no_password_auth:
                  # No auth params were passed, assuming this is unauthenticated
                  # http(s).
                  return True
              if password_ok:
                  if transport == 'http' and not self.insecure_auth:
                      log.critical(
                          'Invalid configuration for {0} remote \'{1}\'. '
                          'Authentication is disabled by default on http '
                          'remotes. Either set {0}_insecure_auth to True in the '
                          'master configuration file, set a per-remote config '
                          'option named \'insecure_auth\' to True, or use https '
                          'or ssh-based authentication.'.format(
                              self.role,
                              self.id
                          )
                      )
                      failhard(self.role)
                  self.credentials = pygit2.UserPass(self.user, self.password)
                  return True
              else:
                  missing_auth = [x for x in required_params
                                  if not bool(getattr(self, x, None))]
                  _incomplete_auth(missing_auth)
          else:
              log.critical(
                  'Invalid configuration for {0} remote \'{1}\'. Unsupported '
                  'transport \'{2}\'.'.format(self.role, self.id, transport)
              )
              failhard(self.role)
code_tokens: def verify_auth ( self ) : self . credentials = None if os . path . isabs ( self . url ) : return True elif not any ( getattr ( self , x , None ) for x in AUTH_PARAMS ) : return True def _incomplete_auth ( missing ) : '''
              Helper function to log errors about missing auth parameters
              ''' log . critical ( 'Incomplete authentication information for %s remote ' '\'%s\'. Missing parameters: %s' , self . role , self . id , ', ' . join ( missing ) ) failhard ( self . role ) def _key_does_not_exist ( key_type , path ) : '''
              Helper function to log errors about missing key file
              ''' log . critical ( 'SSH %s (%s) for %s remote \'%s\' could not be found, path ' 'may be incorrect. Note that it may be necessary to clear ' 'git_pillar locks to proceed once this is resolved and the ' 'master has been started back up. A warning will be logged ' 'if this is the case, with instructions.' , key_type , path , self . role , self . id ) failhard ( self . role ) transport , _ , address = self . url . partition ( '://' ) if not address : transport = 'ssh' address = self . url transport = transport . lower ( ) if transport in ( 'git' , 'file' ) : return True elif 'ssh' in transport : required_params = ( 'pubkey' , 'privkey' ) user = address . split ( '@' ) [ 0 ] if user == address : log . critical ( 'Keypair specified for {0} remote \'{1}\', but remote URL ' 'is missing a username' . format ( self . role , self . id ) ) failhard ( self . role ) self . user = user if all ( bool ( getattr ( self , x , None ) ) for x in required_params ) : keypair_params = [ getattr ( self , x , None ) for x in ( 'user' , 'pubkey' , 'privkey' , 'passphrase' ) ] for idx , key_type in ( ( 1 , 'pubkey' ) , ( 2 , 'privkey' ) ) : key_path = keypair_params [ idx ] if key_path is not None : try : if not os . path . isfile ( key_path ) : _key_does_not_exist ( key_type , key_path ) except TypeError : _key_does_not_exist ( key_type , key_path ) self . credentials = pygit2 . Keypair ( * keypair_params ) return True else : missing_auth = [ x for x in required_params if not bool ( getattr ( self , x , None ) ) ] _incomplete_auth ( missing_auth ) elif 'http' in transport : required_params = ( 'user' , 'password' ) password_ok = all ( bool ( getattr ( self , x , None ) ) for x in required_params ) no_password_auth = not any ( bool ( getattr ( self , x , None ) ) for x in required_params ) if no_password_auth : return True if password_ok : if transport == 'http' and not self . insecure_auth : log . critical ( 'Invalid configuration for {0} remote \'{1}\'. ' 'Authentication is disabled by default on http ' 'remotes. Either set {0}_insecure_auth to True in the ' 'master configuration file, set a per-remote config ' 'option named \'insecure_auth\' to True, or use https ' 'or ssh-based authentication.' . format ( self . role , self . id ) ) failhard ( self . role ) self . credentials = pygit2 . UserPass ( self . user , self . password ) return True else : missing_auth = [ x for x in required_params if not bool ( getattr ( self , x , None ) ) ] _incomplete_auth ( missing_auth ) else : log . critical ( 'Invalid configuration for {0} remote \'{1}\'. Unsupported ' 'transport \'{2}\'.' . format ( self . role , self . id , transport ) ) failhard ( self . role )
short_docstring: Check the username and password/keypair info for validity.
short_docstring_tokens: Check the username and password / keypair info for validity .
comment: '''
          Check the username and password/keypair info for validity. If valid,
          set a 'credentials' attribute consisting of the appropriate Pygit2
          credentials object. Return False if a required auth param is not
          present. Return True if the required auth parameters are present (or
          auth is not configured), otherwise failhard if there is a problem with
          authenticaion.
          '''$SEP$# If the URL is an absolute file path, there is no authentication.$SEP$# Auth information not configured for this remote$SEP$'''
              Helper function to log errors about missing auth parameters
              '''$SEP$'''
              Helper function to log errors about missing key file
              '''$SEP$# Assume scp-like SSH syntax (user@domain.tld:relative/path.git)$SEP$# These transports do not use auth$SEP$# No '@' sign == no user. This is a problem.$SEP$# Check pubkey and privkey to make sure file exists$SEP$# No auth params were passed, assuming this is unauthenticated$SEP$# http(s).