예제 #1
0
파일: app.py 프로젝트: zap-me/zapm_server
def check_auth(api_key_token, nonce, sig, body):
    api_key = ApiKey.from_token(db.session, api_key_token)
    if not api_key:
        return False, "not found", None
    if not api_key.user.active:
        return False, "inactive account", None
    res, reason = check_hmac_auth(api_key, nonce, sig, body)
    if not res:
        return False, reason, None
    # update api key nonce
    db.session.commit()
    return True, "", api_key
예제 #2
0
파일: app.py 프로젝트: zap-me/zapm_server
def transfer_tx_callback(api_keys, txn):
    txt = json.dumps(txn)
    print("transfer_tx_callback: tx %s" % txt)
    for api_key in api_keys:
        print("sending 'tx' event to room %s" % api_key)
        socketio.emit("tx", txt, json=True, room=api_key)
        if not TxNotification.exists(db.session, txn["id"]):
            print("adding to tx notification table")
            api_key = ApiKey.from_token(db.session, api_key)
            txnoti = TxNotification(api_key.user, txn["id"])
            db.session.add(txnoti)
            db.session.commit()
예제 #3
0
def check_auth(session, api_key_token, nonce, sig, body):
    # pylint: disable=import-outside-toplevel
    from models import ApiKey
    api_key = ApiKey.from_token(session, api_key_token)
    if not api_key:
        return False, AUTH_FAILED, None
    if not api_key.user.active:
        return False, AUTH_FAILED, None
    res, reason = check_hmac_auth(api_key, nonce, sig, body)
    if not res:
        return False, reason, None
    # update api key nonce
    session.commit()
    return True, "", api_key