Giter VIP home page Giter VIP logo

aries-cloudagent-webhook-receiver's Introduction

Hyperledger Aries Cloud Agent - Webhook Receiver

The Hyperledger Aries Cloud Agent - Python (ACA-Py) currently requires the ACA-Py controller to host several webhook endpoints in order to receive updates about the agents state as described here. This introduces a problem for mobile ACA-Py controller clients since it is not possible to expose such endpoints.

This repository aims to solve this problem 'the dirty way' by placing another component (called Webhook Receiver) in between ACA-Py and the Controller. The Webhook Receiver exposes the required webhook endpoints and records the requests made by ACA-Py. It also exposes an endpoint and websocket interface to get the recorded messages that the Controller call to process the messages.

A note about the websocket

Whenever a client opens a websocket connection, all in-memory messages that the client has missed so far will be send in the order they came in. (TODO -> create cli flag to make it optional) All new messages will be forwarded directly as long as the websocket connection lives. Whenever the connection is broken we'll start writing into memory again until the next time the client connects.

Setup

Docker Compose

The docker-compose.yml file contains a Alice - Faber test setup where both Alice and Faber have their own Webhook Receiver instance. Just run:

docker-compose build
docker-compose up -d
# and when you're done
docker-compose down

You can now connect to the various components through the following adresses:

Alice Swagger UI: http://127.0.0.1:8002 Webhook Receiver (get new messages): http://127.0.0.1:8080/new_messages Webhook Receiver (websocket): ws://127.0.0.1:8080/ws

Faber Swagger UI: http://127.0.0.1:7002 Webhook Receiver (get new messages): http://127.0.0.1:7080/new_messages Webhook Receiver (websocket): ws://127.0.0.1:7080/ws

Docker

If you prefer a single container version.

docker build -t webhook-receiver .
docker run -p 8080:8080 webhook-receiver 

Manual

# make sure you have virtualenv
pip install virtualenv # or pip3 install virtualenv

# create a virtual environment
virtualenv --python=python3.7 ./webhook-receiver-env

# load it
source ./webhook-receiver-env/bin/activate

# install dependencies
pip install -r requirements.txt

Usage

usage: webhook-receiver [-h] [-w] [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
                        [--api-key API_KEY] [--host HOST] [--port PORT]

collects and cache's aca-py webhook calls until requested by controller.

optional arguments:
  -h, --help            show this help message and exit
  -w, --websocket       when passed, it will expose a websocket interface at
                        ws://HOST:PORT/ws
  -l {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --log {CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        the log level
  --api-key API_KEY     if passed, this will be used as the API key. (one will
                        be generated by default)
  --host HOST, -H HOST
  --port PORT, -p PORT

When you run the webhook-receiver, it will print the following message:

INFO - no api-key provided, generating one..

INFO - log level:               INFO
INFO - websocket enabled at:    ws://0.0.0.0:8080/ws
INFO - API Key:                 55c56521-df27-4284-a71b-04501cd49c5b

======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)

Copy th printed address (in this case http://0.0.0.0:8080) and pass it to a ACA-Py instance as the --webhook-url argument. All webhook requests made by ACA-Py will now be directed towards the webhook-receiver. Your Controller instance can now fetch the messages by calling http://0.0.0.0:8080/new-messages or subscribe to the websocket interface at http://0.0.0.0:8080/ws. Please note that both methods require the Authorization request header to be set to the webhook-receivers API key (in this case 55c56521-df27-4284-a71b-04501cd49c5b).

aries-cloudagent-webhook-receiver's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.