Exemple #1
0
def submit_session(action=None,
                   source=None,
                   mac=None,
                   ipv4=None,
                   ipv6=None,
                   time=None,
                   key=None):
    strmac = mac.rawstr()
    strtime = time.strftime('%Y-%m-%dT%H:%M:%S')
    params = {
        'action': action,
        'source': source,
        'mac': strmac,
        'time': strtime
    }
    if ipv4:
        params['ipv4'] = str(ipv4)
    if ipv6:
        params['ipv6'] = str(ipv6)
    body = urllib.parse.urlencode(params).encode('ascii')
    params['key'] = key
    auth_header = common.gen_authorization_header(**params)
    req = urllib.request.Request(SESSION_URL, data=body)
    req.add_header('Authorization', auth_header)
    LOGGER.debug("Submitting session: %s (%s)", body, auth_header)
    urllib.request.urlopen(req)
Exemple #2
0
    def authenticate_session_request(self):
        """Ensures that the current request is properly signed. Raises an
        exception if the signature is invalid. Performs no validation that the
        parameters are sensible.

        """
        args = dict(cherrypy.request.body.params)
        args['key'] = config.SESSION_KEYS[args['source']]
        if cherrypy.request.headers['Authorization'] != common.gen_authorization_header(**args):
            raise Exception('Invalid HMAC signature')
Exemple #3
0
    def authenticate_session_request(self):
        """Ensures that the current request is properly signed. Raises an
        exception if the signature is invalid. Performs no validation that the
        parameters are sensible.

        """
        args = dict(cherrypy.request.body.params)
        args['key'] = config.SESSION_KEYS[args['source']]
        if cherrypy.request.headers[
                'Authorization'] != common.gen_authorization_header(**args):
            raise Exception('Invalid HMAC signature')
Exemple #4
0
def submit_session(action=None, source=None, mac=None, ipv4=None, ipv6=None,
                   time=None, key=None):
    strmac = mac.rawstr()
    strtime = time.strftime('%Y-%m-%dT%H:%M:%S')
    params = {'action': action, 'source': source, 'mac': strmac, 'time': strtime}
    if ipv4:
        params['ipv4'] = str(ipv4)
    if ipv6:
        params['ipv6'] = str(ipv6)
    body = urllib.parse.urlencode(params).encode('ascii')
    params['key'] = key
    auth_header = common.gen_authorization_header(**params)
    req = urllib.request.Request(SESSION_URL, data=body)
    req.add_header('Authorization', auth_header)
    LOGGER.debug("Submitting session: %s (%s)", body, auth_header)
    urllib.request.urlopen(req)