Code Monkey home page Code Monkey logo

alma-webhook-handler's Introduction

alma-webhook-handler

A serverless application on AWS Lambda for handling Alma webhooks, and passing them to SNS topics.

This service is built on the serverless framework.

The service handles 8 specific webhook event types. These are LOAN_CREATED, LOAN_RENEWED, LOAN_DUE_DATE, LOAN_RETURNED, REQUEST_CREATED, REQUEST_CANCELED, REQUEST_CLOSED AND REQUEST_PLACED_ON_SHELF. For each of these event types the service defines and creates an AWS SNS topic, to which it writes the specific event data. Subscriptions can be set up on these topics to make use of these data. The LAG-sns-update-cache service is intended to subscribe to these topics to use the data for caching purposes.

The service consists of two AWS Lambda functions, challenge-handler and webhook-handler.

challenge-handler

The challenge-handler handles the initial challenge request made by the Alma webhook API. The Alma API makes an HTTP GET request to the provided endpoint with a random challenge parameter. The challenge-handler returns this challenge parameter back, with a 200 response.

webhook-handler

The webhook-handler then handles the webhook events from the Alma webhook API. These are HTTP POST requests with the event data sent in the request body. The POST request also includes an X-Exl-Signature header to validate the webhook data. This is a SHA-256 HMAC of the request body, using a user defined secret key supplied to Alma. The Lambda verifies this signature by computing the HMAC of the received data. The secret is stored in AWS SSM and retrieved from it at runtime. If the signatures do not match the Lambda will return a 401 error and will not write any data to SNS.

Usage

The service can be deployed using the command sls deploy --stage <STAGE> --region <REGION>

There are three valid stages defined in the serverless.yml configuration file. These are dev, stg and prod. An environment variable ALMA_SHARED_SECRET_NAME must be defined, which should be the name of the SSM parameter for the Alma shared secret. Note that all names of SSM parameters start with a slash /.

On deployment the service will create all necessary resources with the exception of the SSM Parameter, which must be created separately. It is recommended to simply generate a random string for the shared secret.

Associated Services

There are four services that make up the Alma caching stack. These are:

There are also 3 custom packages on which these depend. These are:

Development

Contributions to this service or any of the associated services and packages are welcome.

alma-webhook-handler's People

Contributors

dombelcher avatar stephenrob avatar

Stargazers

jim hahn avatar Kate Lynch avatar

Watchers

James Cloos avatar Masud Khokhar avatar  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.