From c02d03854b1494061b05113eeb2a063b492f0eae Mon Sep 17 00:00:00 2001 From: ywkim312 Date: Tue, 4 Aug 2020 16:38:53 -0500 Subject: [PATCH] Task/523 update auth middleware test README (#527) * added connexion in requirements.txt * modified readme direction Co-authored-by: Sandeep Puthanveetil Satheesan --- CHANGELOG.md | 1 + auth-middleware-test-svc/Dockerfile | 2 +- .../{readme.md => README.md} | 52 ++++++++++++------- auth-middleware-test-svc/docker-compose.yml | 8 --- auth-middleware-test-svc/flaskapp.py | 2 +- auth-middleware-test-svc/requirements.txt | 1 + 6 files changed, 37 insertions(+), 29 deletions(-) rename auth-middleware-test-svc/{readme.md => README.md} (51%) delete mode 100644 auth-middleware-test-svc/docker-compose.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 73a954ef..74556b4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update Authentication Building Block docker base image. [#517](https://github.com/rokwire/rokwire-building-blocks-api/issues/517) - Update Authentication Building Block README [#519](https://github.com/rokwire/rokwire-building-blocks-api/issues/519) - Changed docker base image for Profile and Logging Building Block. [#521](https://github.com/rokwire/rokwire-building-blocks-api/issues/521) +- Changed README for auth-middleware-test-svc based on new change. [#523](https://github.com/rokwire/rokwire-building-blocks-api/issues/523) ### Removed - rokwire.yaml file and deployment scripts that were not getting used. [#486](https://github.com/rokwire/rokwire-building-blocks-api/issues/486) diff --git a/auth-middleware-test-svc/Dockerfile b/auth-middleware-test-svc/Dockerfile index 800e45f3..79caebac 100644 --- a/auth-middleware-test-svc/Dockerfile +++ b/auth-middleware-test-svc/Dockerfile @@ -1,6 +1,6 @@ FROM python:3 -LABEL maintainer="fhena2@illinois.edu" +LABEL maintainer="ywkim@illinois.edu" WORKDIR /app COPY auth-middleware-test-svc /app/ diff --git a/auth-middleware-test-svc/readme.md b/auth-middleware-test-svc/README.md similarity index 51% rename from auth-middleware-test-svc/readme.md rename to auth-middleware-test-svc/README.md index 10dad194..7eaded71 100644 --- a/auth-middleware-test-svc/readme.md +++ b/auth-middleware-test-svc/README.md @@ -16,29 +16,43 @@ Pay attention to these things: - [docker build instructions here](#docker-build) - See the readme.md file for the `lib/auth-middleware` python package for environment variables that will need to be set in your building block instance. -## run +## Environment File -- make present-working-directory this one (`rokwire-building-blocks-api/auth-middleware-test-svc/`) -- execute run command - - docker compose - - `$ docker-compose up` - - standard python (need to pip install requirements, and recommend using a virtualenv) - - `$ python flaskapp.py` +You need to have a `.env` file in this directory that contains credentials required for authentication. +Not all of these variables may be required for this test. -## docker build +Example file format: +``` +TWILIO_ACCT_SID= +TWILIO_AUTH_TOKEN= +TWILIO_VERIFY_SERVICE_ID= -## Environment variables -Please add the required environment variables to .env file. This will be imported into the docker container when running docker compose command. +PHONE_VERIFY_SECRET= +PHONE_VERIFY_AUDIENCE= -### std docker +SHIBBOLETH_HOST= +SHIBBOLETH_CLIENT_ID= +``` -- make present-working-directory the parent directory - - eg. - - this project = `rokwire-building-blocks-api/auth-middleware-test-svc` - - parent directory = `rokwire-building-blocks-api` - build context -- `$ docker build -f auth-middleware-test-svc/Dockerfile .` +## Run application -### docker compose +### Run locally without Docker +``` +cd rokwire-building-blocks-api/auth-middleware-test-svc +virtualenv -p python3 venv +source venv/bin/activate +pip install -r requirements.txt +python flaskapp.py` +``` -- make present-working-directory this one (`rokwire-building-blocks-api/auth-middleware-test-svc/`) -- `$ docker-compose build` +If you want to use gunicorn, cd into api folder then, use ` gunicorn flaskapp:app -c gunicorn.config.py` instead of `python flaskapp.py` + +It should be running at http://localhost:5000 + +### Docker Instructions + +``` +cd rokwire-building-blocks-api +docker build -t rokwire/auth_middleware_test -f auth-middleware-test-svc/Dockerfile . +docker run --rm --env-file=auth-middleware-test-svc/.env -p 5000:5000 rokwire/auth_middleware_test +``` diff --git a/auth-middleware-test-svc/docker-compose.yml b/auth-middleware-test-svc/docker-compose.yml deleted file mode 100644 index b5893c52..00000000 --- a/auth-middleware-test-svc/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3' -services: - web: - build: - context: ../ - dockerfile: auth-middleware-test-svc/Dockerfile - ports: ["5000:5000"] - env_file: .env diff --git a/auth-middleware-test-svc/flaskapp.py b/auth-middleware-test-svc/flaskapp.py index 62c1372a..13516db8 100644 --- a/auth-middleware-test-svc/flaskapp.py +++ b/auth-middleware-test-svc/flaskapp.py @@ -20,7 +20,7 @@ ################################################ # Call middleware here! -# ⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ +################################################ app.before_request(auth_middleware.authenticate) diff --git a/auth-middleware-test-svc/requirements.txt b/auth-middleware-test-svc/requirements.txt index 22d0e072..593dbf0a 100644 --- a/auth-middleware-test-svc/requirements.txt +++ b/auth-middleware-test-svc/requirements.txt @@ -1,4 +1,5 @@ Flask==1.1.1 gunicorn==19.9.0 +connexion[swagger-ui]==2.4.0 ../lib/auth-middleware