Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Files

Latest commit

cbd64e9 · Jul 23, 2020

History

History

flask

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 23, 2020
Jul 23, 2020
Mar 20, 2020
Mar 20, 2020

Flask + SecretHub


This Flask example checks if the environment variables DEMO_USERNAME and DEMO_PASSWORD have been set. If that's the case, you'll receive a 200 on http://localhost:8080 and if it's not, you'll get a 500.

Prerequisites

  1. Docker installed and running
  2. SecretHub installed
  3. A SecretHub repo that contains a username and password secret. To create it, run secrethub demo init.

Running the example

Set the SecretHub username in an environment variable

export SECRETHUB_USERNAME=<your-username>

Create a service account for the demo repo

secrethub service init --description demo_service \
--permission read --file demo_service.cred ${SECRETHUB_USERNAME}/demo

Build the flask docker demo

docker build . -t flask-secrethub-demo

Run the docker demo with the secrets in the environment variables

docker run -ti -p 8080:5000 \
  -e DEMO_USERNAME=secrethub://${SECRETHUB_USERNAME}/demo/username \
  -e DEMO_PASSWORD=secrethub://${SECRETHUB_USERNAME}/demo/password \
  -e SECRETHUB_CREDENTIAL=$(cat demo_service.cred) \
  flask-secrethub-demo

If you now visit http://localhost:8080, you should see the welcome message including your username.