Ejemplo n.º 1
0
def verify_message(core, handler, tns, msgDict):
    '''
        verify signature and return decrypted message if valid
        if not, None will be returned
    '''
    if handler.get_argument('msg_signature', ''):
        valid = oauth(*(tns + [core.config.token, msgDict.get('Encrypt', '')]))
    else:
        valid = oauth(*(tns + [core.config.token]))
    if valid:
        if core.config.encryptMode == SAFE:
            msgDict = decrypt_msg(*(tns + [core.config, msgDict]))
    else:
        msgDict = {}
    return msgDict
Ejemplo n.º 2
0
def verify_echostr(core, handler):
    '''
        verify signature and return echostr if valid
        if not, None will be returned
    '''
    tns = get_tns(core, handler)
    echostr = handler.get_argument('echostr', '')
    if handler.get_argument('msg_signature', ''):
        if oauth(*(tns + [echostr, core.config.token])):
            msgDict = decrypt_msg(*(tns + [core.config, {'echostr': echostr}]))
            echostr = msgDict.get('echostr')
    else:
        valid = oauth(*(tns + [core.config.token]))
        if not valid:
            echostr = None
    return echostr
Ejemplo n.º 3
0
def verify_echostr(core, handler):
    '''
        verify signature and return echostr if valid
        if not, None will be returned
    '''
    echostr = handler.get_argument('echostr', '')
    if handler.get_argument('msg_signature', ''):
        tns = [
            handler.get_argument(key, '')
            for key in ('timestamp', 'nonce', 'msg_signature')
        ]
        if oauth(*(tns + [echostr, core.config.token])):
            echostr = decrypt_msg(*(tns + [core.config, {'echostr': echostr}]))
            echostr = echostr.get('echostr')
    else:
        valid = oauth(*([
            handler.get_argument(key, '')
            for key in ('timestamp', 'nonce', 'signature')
        ] + [core.config.token]))
        if not valid: echostr = None
    return echostr