예제 #1
0
파일: xmlrpc.py 프로젝트: NETWAYS/ingraph
         def parse_request(myself):
             if SimpleXMLRPCRequestHandler.parse_request(myself):
                 header = myself.headers.get('Authorization')
                 
                 if header == None:
                     username = None
                     password = None
                 else:                    
                     (basic, encoded) = \
                         header.split(' ', 2)
 
                     assert basic == 'Basic', 'Only basic authentication supported'
                     
                     (username,
                      password) = base64.b64decode(encoded).split(':', 2)
                 
                 if self.authenticate(username, password):
                     return True
                 else:
                     myself.send_response(401, 'Authentication failed')
                     myself.send_header('WWW-Authenticate',
                                        'Basic realm="XML-RPC"')
                     myself.end_headers()
                     
                     myself.wfile.write('Authentication failed.')
             
             return False
예제 #2
0
파일: server.py 프로젝트: tianon/debile
 def parse_request(self, *args):
     if SimpleXMLRPCRequestHandler.parse_request(self, *args):
         if self.authenticate():
             return True
         else:
             self.send_error(401, 'Authentication failed')
     return False
 def parse_request(request):
     if SimpleXMLRPCRequestHandler.parse_request(request):
         if self.authenticate(request.headers):
             return True
         else:
             request.send_error(401, "Authentication failed, Try again.")
     return False
예제 #4
0
파일: server.py 프로젝트: paultag/lucy
 def parse_request(self, *args):
     if SimpleXMLRPCRequestHandler.parse_request(self, *args):
         if self.authenticate():
             return True
         else:
             self.send_error(401, 'Authentication failed')
     return False
예제 #5
0
    def parse_request(self):
        """Http version checking and connection close, force Basic Authentication"""

        import base64
        try:
            from urllib import unquote as unquote_to_bytes
        except ImportError:
            from urllib.parse import unquote_to_bytes

        isValid = False
        if SimpleXMLRPCRequestHandler.parse_request(self):
            enctype, encstr = self.headers.get('Authorization').split()
            encstr = base64.b64decode(encstr).decode("utf-8")
            emailid, password = encstr.split(':')
            emailid = unquote_to_bytes(emailid).decode("utf-8")
            password = unquote_to_bytes(password).decode("utf-8")
            isValid = emailid == BMConfigParser().get('bitmessagesettings', 'apiusername') and password == BMConfigParser().get('bitmessagesettings', 'apipassword')
        else:
            logger.warning(
                'Authentication failed because header lacks'
                ' Authentication field')
            time.sleep(2)

        if isValid is False:
            self.send_error(401, b'Authetication failed')

        return isValid
예제 #6
0
 def parse_request(self):
     if SimpleXMLRPCRequestHandler.parse_request(self):
         if self.authenticate(self.headers):
             return True
         else:
             self.send_error(401, "Authentication Failed")
             return False
예제 #7
0
파일: xmlrpc.py 프로젝트: NETWAYS/ingraph
            def parse_request(myself):
                if SimpleXMLRPCRequestHandler.parse_request(myself):
                    header = myself.headers.get('Authorization')

                    if header == None:
                        username = None
                        password = None
                    else:
                        (basic, encoded) = \
                            header.split(' ', 2)

                        assert basic == 'Basic', 'Only basic authentication supported'

                        (username,
                         password) = base64.b64decode(encoded).split(':', 2)

                    if self.authenticate(username, password):
                        return True
                    else:
                        myself.send_response(401, 'Authentication failed')
                        myself.send_header('WWW-Authenticate',
                                           'Basic realm="XML-RPC"')
                        myself.end_headers()

                        myself.wfile.write('Authentication failed.')

                return False
예제 #8
0
 def parse_request(request):
     if SimpleXMLRPCRequestHandler.parse_request(request):
         if self.authenticate(request.headers):
             return True
         else:
             request.send_error(401,
                                'Authentication failed,Try again.')
     return False
예제 #9
0
            def parse_request(this):
                if SimpleXMLRPCRequestHandler.parse_request(this):
                    if self.authenticate(this.headers):
                        return True
                else:
                    this.send_error(401, "Authentication failed")

                return False
예제 #10
0
 def parse_request(request):
     if SimpleXMLRPCRequestHandler.parse_request(request):
         # Authenticate
         if self.authenticate(request.headers):
             return True
         else:
             # If authentication fails return 401
             request.send_error(401, 'Authentication failed, Try agin.')
     return False
예제 #11
0
 def parse_request(self):
     if SimpleXMLRPCRequestHandler.parse_request(self):
         # next we authenticate
         if self.authenticate(self.headers):
             return True
         else:
             # if authentication fails, tell the client
             self.send_error(401, 'Authentication failed')
     return False
예제 #12
0
 def parse_request(self):        
     if SimpleXMLRPCRequestHandler.parse_request(self):
         # next we authenticate
         if self.authenticate(self.headers):
             return True
         else:
             # if authentication fails, tell the client
             self.send_error(401, 'Authentication failed')
     return False
예제 #13
0
파일: nosqlite.py 프로젝트: fredstro/mfdb
 def parse_request(myself):
     # first, call the original implementation which returns
     # True if all OK so far
     if SimpleXMLRPCRequestHandler.parse_request(myself):
         # next we authenticate
         if self.authenticate(myself.headers):
             return True
         else:
             # if authentication fails, tell the client
             myself.send_error(401, 'Authentication failed')
     return False
예제 #14
0
 def parse_request(myself):
     # first, call the original implementation which returns
     # True if all OK so far
     if SimpleXMLRPCRequestHandler.parse_request(myself):
         # next we authenticate
         if self.authenticate(myself.headers):
             return True
         else:
             # if authentication fails, tell the client
             myself.send_error(401, 'Authentication failed')
     return False
예제 #15
0
    def parse_request(self):
        '''Parses incoming requests and perform user authentication

        '''
        if SimpleXMLRPCRequestHandler.parse_request(self):
            ret, error_msg, error_code = self.authenticate(self.headers)
            if ret:
                return True
            else:
                self.send_error(error_code, error_msg)
        return False
예제 #16
0
 def parse_request(self):
     # parser request, get authentication header and send to authenticate().
     if SimpleXMLRPCRequestHandler.parse_request(self):
         if self.authenticate(self.headers):
             logging.info("Hass RequestHandler - Authentication success, request from %s", self.clientip)
             return True
         else:
             self.send_error(401, 'Authentication failed')
             return False
     else:
         logging.info("Hass RequestHandler - Authentication failed, request from %s", self.clientip)
         return False
예제 #17
0
파일: Hass.py 프로젝트: yafish/HASS-Project
 def parse_request(self):
 # parser request, get authentication header and send to authenticate().
     if SimpleXMLRPCRequestHandler.parse_request(self):
         if self.authenticate(self.headers):
             logging.info("Hass RequestHandler - Authentication success, request from %s", self.clientip)
             return True
         else:
             self.send_error(401, 'Authentication failed')
             return False
     else:
         logging.info("Hass RequestHandler - Authentication failed, request from %s", self.clientip)
         return False
예제 #18
0
    def parse_request(self):
        log(5, "XMLRPC Request, peer: %s, cipher: %s" % \
                (str(self.connection.getpeername()),
                str(self.connection.cipher())))

        log(6, "XMLRPC Request, Peer Cert: %s" % \
                str(self.connection.getpeercert()))

        if SimpleXMLRPCRequestHandler.parse_request(self):
            return True

        return True