Skip to content

Commit

Permalink
Remove some leftovers of the auth server (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaryaz committed Oct 31, 2018
1 parent 97df206 commit e5003d3
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 257 deletions.
45 changes: 4 additions & 41 deletions registry/README.md
Expand Up @@ -101,7 +101,7 @@ sudo vi /etc/hosts
and add this line:

```bash
127.0.0.1 auth s3 flask catalog
127.0.0.1 s3 flask catalog
```

then run:
Expand All @@ -124,7 +124,7 @@ To browse the catalog using a web browser, enter this location into your web bro
Running a Quilt Registry in AWS requires the following services:
* a Postgres database. You can find instructions for setting up Postgres in RDS here: [Create a Postres Database in RDS](https://aws.amazon.com/rds/postgresql/)
* an S3 bucket
* an EC2 instance to run the registry, authentication service and catalog. Add the following policies to the security group: Postgres, HTTP/HTTPS, SSH and a custom TCP rule to enable port 5000.
* an EC2 instance to run the registry and catalog. Add the following policies to the security group: Postgres, HTTP/HTTPS, SSH and a custom TCP rule to enable port 5000.
* an Elastic Load Balancer (ELB) to terminate SSL connections to the registry and catalog

Once the resources have been created, ssh into the EC2 instance and configure the environment and run the services via Docker. You can make it easier to connect to your registry by creating a new DNS record to point to the EC2 instance's external IP address (e.g., quilt.yourdomain.com).
Expand Down Expand Up @@ -183,36 +183,10 @@ sudo docker run -d -e UWSGI_HOST=localhost -e UWSGI_PORT=9000 -e NGINX_PORT=80 -

Server installations (e.g. AWS) require special instructions because the web browser is not running on the same machine as the Quilt registry. For this example, let's assume that your server has an external IP address of ```$EXT_IP```

First, modify your ```/etc/hosts``` from this: ```127.0.0.1   auth s3 flask catalog``` to this: ```$EXT_IP auth s3 flask catalog```.
First, modify your ```/etc/hosts``` from this: ```127.0.0.1   s3 flask catalog``` to this: ```$EXT_IP s3 flask catalog```.

Second, if your server has a firewall protecting against inbound connections (and most do!), you need to either (a) install and use a text browser such as [lynx](https://lynx.browser.org/) (on Ubuntu: ```apt-get install lynx; lynx http://localhost:5000/login```), (b) disable the firewall temporarily using port-forwarding [instructions for AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html), or (c) setup an [SSH tunnel](https://www.revsys.com/writings/quicktips/ssh-tunnel.html) so that your laptop browser can connect to your server instance behind its firewall.

### Advanced: GitHub Authentication

You can let users signup/login to your registry using their credentials on GitHub, where their github username (e.g. "asah") is used for their Quilt registry username.

1. Create a new OAuth Application on GitHub ([link](https://github.com/settings/applications/new))
Homepage URL: ```http://localhost:3000```
Authorization callback URL: ```http://flask:5000/oauth_callback```

2. Save your new application's client ID and client secret to the local environment:
```bash
export OAUTH_CLIENT_ID_GITHUB=<OAUTH_APP_CLIENT_ID>
export OAUTH_CLIENT_SECRET_GITHUB=<OAUTH_APP_CLIENT_SECRET>
```

3. Run this command to start the registry and it will automatically use GitHub OAuth for user authentication, instead of its local database:
```bash
docker-compose -f docker-compose-github-auth.yml up
```

Look for this line in the output, which indicates that the server is using github for authentication:
```bash
flask_1 | AUTH_PROVIDER=github
```

4. When users run ```quilt login``` their browser should be redirected to a page on github.com which handles login to the catalog webserver (via cookies/rediects) and also generates the access token for the Quilt client (command-line tools, Python API, etc).

### Advanced: Modifying Components

Developers who make changes to source code in the registry, catalog or s3 proxy can follow these steps:
Expand Down Expand Up @@ -271,17 +245,6 @@ If you are very careful, you can run Quilt directly in your host operating syste
export FLASK_DEBUG=1
export QUILT_SERVER_CONFIG=dev_config.py
# 1) Quilt auth:
# Get this one from the stage API app
# (https://quilt-heroku.herokuapp.com/admin/oauth2_provider/application/3/)
export OAUTH_CLIENT_SECRET_QUILT=...
# 2) GitHub auth:
export AUTH_PROVIDER=github
# Get this one from the GitHub API app
# (https://github.com/settings/applications/594774)
export OAUTH_CLIENT_SECRET_GITHUB=...
# Optional: set a Mixpanel token (for the "Debug" project)
export MIXPANEL_PROJECT_TOKEN=247b6756f3a8616f9369351b0e5e1fe9
Expand Down Expand Up @@ -367,7 +330,7 @@ sudo docker-compose -f docker-compose-dev.yml up
``` bash
workon quilt
cd quilt/registry
sudo echo "127.0.0.1 auth s3 flask catalog" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 s3 flask catalog" | sudo tee -a /etc/hosts
source quilt_server/flask_dev.sh
```

Expand Down
21 changes: 0 additions & 21 deletions registry/auth/Dockerfile

This file was deleted.

29 changes: 0 additions & 29 deletions registry/auth/authserver.py

This file was deleted.

73 changes: 0 additions & 73 deletions registry/docker-compose-github-auth.yml

This file was deleted.

83 changes: 0 additions & 83 deletions registry/docker-compose-local-auth.yml

This file was deleted.

1 change: 0 additions & 1 deletion registry/docker-compose.yml

This file was deleted.

83 changes: 83 additions & 0 deletions registry/docker-compose.yml
@@ -0,0 +1,83 @@
version: '2.1'
services:
db:
image: postgres
environment:
- POSTGRES_PASSWORD=testing
- POSTGRES_DB=packages
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 3s
retries: 3
ports:
- "5432:5432"

flaskmigration:
build: .
image: quiltdata/registry
environment:
- AWS_ACCESS_KEY_ID=ddccbbaa
- AWS_SECRET_ACCESS_KEY=abcd
- QUILT_SERVER_CONFIG=dev_config.py
- SQLALCHEMY_DATABASE_URI=postgresql://postgres:testing@db/packages
- REGISTRY_URL=http://localhost:5000
- QUILT_SECRET_KEY=aaaaaaaaaa
depends_on:
db:
condition: service_healthy
command:
flask db upgrade

flask:
build: .
image: quiltdata/registry
environment:
- AWS_ACCESS_KEY_ID=ddccbbaa
- AWS_SECRET_ACCESS_KEY=abcd
- QUILT_SERVER_CONFIG=dev_config.py
- SQLALCHEMY_DATABASE_URI=postgresql://postgres:testing@db/packages
- DEPLOYMENT_ID=dev
- REGISTRY_URL=http://localhost:5000
- QUILT_SECRET_KEY=aaaaaaaaaa
- S3_ENDPOINT = http://s3:5001
- DISABLE_SIGNUP
- ENABLE_USER_ENDPOINTS
- TEAM_ID
- TEAM_NAME
- ALLOW_ANONYMOUS_ACCESS
- ALLOW_TEAM_ACCESS
depends_on:
db:
condition: service_healthy

nginxflask:
image: nginx:latest
ports:
- "5000:80"
depends_on:
- flask
volumes:
- ./nginx/nginx-quilt.conf:/etc/nginx/nginx-quilt.template
environment:
- UWSGI_HOST=flask
- UWSGI_PORT=9000
- NGINX_PORT=80
command: /bin/bash -c "envsubst < /etc/nginx/nginx-quilt.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

s3:
build: nginx-s3
image: quiltdata/nginx-s3-proxy
ports:
- "5001:5001"

catalog:
build: ../catalog
image: quiltdata/catalog
environment:
- REGISTRY_URL=http://flask:5000
- STRIPE_KEY=NOSTRIPE
- TEAM_ID
- TEAM_NAME
ports:
- "3000:80"
6 changes: 0 additions & 6 deletions registry/quilt_server/dev_config.py
Expand Up @@ -10,12 +10,6 @@

SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI', 'postgresql://postgres@localhost/packages')

AUTH_PROVIDER = os.getenv('AUTH_PROVIDER', 'quilt')

STAGE_AUTH_URL = 'https://stage-auth.quiltdata.com'

QUILT_AUTH_URL = os.getenv('QUILT_AUTH_URL', STAGE_AUTH_URL)

CATALOG_URL = 'http://localhost:3000'

REGISTRY_URL = 'http://localhost:5000'
Expand Down

0 comments on commit e5003d3

Please sign in to comment.