Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

ONSdigital/sdx-decrypt

Repository files navigation

sdx-decrypt

Build Status Codacy Badge

sdx-decrypt is a decryption service written in Python. It is a component of the Office of National Statistics (ONS) Survey Data Exchange (SDX) project, which takes an encrypted json payload and transforms it into a number of formats for use within the ONS.

sdx-decrypt uses JSON Web Tokens to decrypt data.

Installation

This application presently installs required packages from requirements files:

  • requirements.txt: packages for the application, with hashes for all packages: see https://pypi.org/project/hashin/
  • test-requirements.txt: packages for testing and linting

It's also best to use pyenv and pyenv-virtualenv, to build in a virtual environment with the currently recommended version of Python. To install these, see:

Getting started

Once your virtual environment is set, install the requirements:

$ make build

To test, first run make build as above, then run:

$ make test

It's also possible to install within a container using docker. From the sdx-decrypt directory:

$ docker build -t sdx-decrypt .

Usage

To start sdx-decrypt, just run the server:

$ python server.py

API

  • POST /decrypt - decrypts and returns the data it is sent as JSON
  • GET /healthcheck - returns a JSON response with a key/value pairs describing the service state

Example

The example below uses the Python library requests to decrypt some data using sdx-decrypt.

import requests

r = requests.post('http://127.0.0.1:5000/decrypt', data=encrypted_data)

decrypted_data = r.text

Configuration

Compulsory environment variables available for configuration are listed below:

Environment Variable Description
EQ_PUBLIC_KEY Location of EQ public key
PRIVATE_KEY Location of private key
PRIVATE_KEY_PASSWORD Private key password

License

Copyright © 2016, Office for National Statistics (https://www.ons.gov.uk)

Released under MIT license, see LICENSE for details.