Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

AWS Serverless Application - Listens for Ex-Libris Alma web-hook events and passes these to backend SNS topics.

License

Notifications You must be signed in to change notification settings

lulibrary/alma-webhook-handler

Repository files navigation

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.

About

AWS Serverless Application - Listens for Ex-Libris Alma web-hook events and passes these to backend SNS topics.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published