Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/523 check read auth middleware test #527

Merged
merged 3 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion auth-middleware-test-svc/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 Account SID>
TWILIO_AUTH_TOKEN=<Twilio Auth Token>
TWILIO_VERIFY_SERVICE_ID=<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 Secret>
PHONE_VERIFY_AUDIENCE=<Phone Verify Audience>

### std docker
SHIBBOLETH_HOST=<Shibboleth Host Name>
SHIBBOLETH_CLIENT_ID=<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
```
8 changes: 0 additions & 8 deletions auth-middleware-test-svc/docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion auth-middleware-test-svc/flaskapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

################################################
# Call middleware here!
# ⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇
################################################
app.before_request(auth_middleware.authenticate)


Expand Down
1 change: 1 addition & 0 deletions auth-middleware-test-svc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Flask==1.1.1
gunicorn==19.9.0
connexion[swagger-ui]==2.4.0

../lib/auth-middleware