Skip to content

Commit

Permalink
Fix proxy and redirects for globus auth on docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Price committed Dec 7, 2024
1 parent 18ba9dc commit a10c8a8
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 202 deletions.
14 changes: 12 additions & 2 deletions backend/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@
"urn:globus:auth:scope:transfer.api.globus.org:all",
]

SOCIAL_AUTH_GLOBUS_KEY = env("GLOBUS_CLIENT_KEY", default="12345")
SOCIAL_AUTH_GLOBUS_SECRET = env("GLOBUS_CLIENT_SECRET", default="12345")
SOCIAL_AUTH_GLOBUS_KEY = env("GLOBUS_CLIENT_KEY", default="unset")
SOCIAL_AUTH_GLOBUS_SECRET = env("GLOBUS_CLIENT_SECRET", default="unset")
SOCIAL_AUTH_GLOBUS_AUTH_EXTRA_ARGUMENTS = {
"requested_scopes": SOCIAL_AUTH_GLOBUS_SCOPE,
"prompt": None,
Expand Down Expand Up @@ -427,6 +427,9 @@
),
}

# Custom settings validation
# -------------------------------------------------------------------------------

if not isinstance(FRONTEND_SETTINGS["REACT_APP_GLOBUS_NODES"], list):
raise environ.ImproperlyConfigured(
f"REACT_APP_GLOBUS_NODES must be of type list, not "
Expand All @@ -442,3 +445,10 @@
f"REACT_APP_AUTHENTICATION_METHOD must be one of keycloak or globus, "
f"not {FRONTEND_SETTINGS['REACT_APP_AUTHENTICATION_METHOD']}"
)

if FRONTEND_SETTINGS["REACT_APP_AUTHENTICATION_METHOD"] == "globus" and (
SOCIAL_AUTH_GLOBUS_KEY == "unset" or SOCIAL_AUTH_GLOBUS_SECRET == "unset"
):
raise environ.ImproperlyConfigured(
"When REACT_APP_AUTHENTICATION_METHOD is 'globus', both SOCIAL_AUTH_GLOBUS_KEY and SOCIAL_AUTH_GLOBUS_SECRET must be set via the environment variables GLOBUS_CLIENT_KEY and GLOBUS_CLIENT_SECRET respectively. You must obtain these credentials by registering a Portal at https://app.globus.org/settings/developers"
)
1 change: 1 addition & 0 deletions docker-compose.prod-overlay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ services:
react:
build:
target: prod
volumes: []
44 changes: 15 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
networks:
metagrid:
ipam:
config:
- subnet: 10.89.9.0/24

volumes:
local_postgres_data: {}
local_postgres_data_backups: {}

services:
postgres:
# This service uses the production Postgres Dockerfile as a base
# Some tweaks are applied to support the Keycloak service, including the init.sql script
build: postgres
image: metagrid_local_postgres
volumes:
- local_postgres_data:/var/lib/postgresql/data
- local_postgres_data_backups:/local_postgres_data_backups
env_file:
- ./metagrid_configs/.local_config
environment:
- PGHOST=${PGHOST:-localhost}
- PGPASSWORD=${PGPASSWORD:-postgres}
- PGUSER=${PGUSER:-postgres}
ports:
- 5432:5432
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "postgres" ]
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "postgres"]
start_period: 5s
interval: 5s
timeout: 2s
retries: 6
networks:
metagrid:
ipv4_address: 10.89.9.81
aliases:
- postgres

django:
build: backend
Expand All @@ -41,15 +30,15 @@ services:
condition: service_healthy
volumes:
- ./backend:/app
env_file:
- ./metagrid_configs/.local_config
ports:
- 5000:5000
networks:
metagrid:
ipv4_address: 10.89.9.82
aliases:
- django
network_mode: host
environment:
- GLOBUS_CLIENT_KEY=${GLOBUS_CLIENT_KEY}
- GLOBUS_CLIENT_SECRET=${GLOBUS_CLIENT_SECRET}
- PGHOST=${PGHOST:-localhost}
- PGPASSWORD=${PGPASSWORD:-postgres}
- PGUSER=${PGUSER:-postgres}

react:
build:
Expand All @@ -60,9 +49,9 @@ services:
- PORT=8080
depends_on:
- django
networks:
metagrid:
ipv4_address: 10.89.9.83
volumes:
- ./frontend:/app
network_mode: host
ports:
- 8080:8080

Expand All @@ -75,9 +64,6 @@ services:
- ./keycloak/realm.json:/opt/keycloak/data/import/realm.json
ports:
- 1337:8080
networks:
metagrid:
ipv4_address: 10.89.9.84

docs:
build: docs
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/NavBar/RightMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const RightMenu: React.FC<React.PropsWithChildren<Props>> = ({
<Button
type="text"
icon={<UserOutlined style={{ fontSize: '18px', margin: 0 }} />}
href="login/globus"
href="login/globus/"
>
Sign In
</Button>
Expand Down
19 changes: 11 additions & 8 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ export default defineConfig(() => {
host: true,
port: 8080,
strictPort: true,
watch: true,
proxy: {
'/frontend-config.js': 'http://django:5000',
'/api': 'http://django:5000',
'/accounts': 'http://django:5000',
'/account-confirm-email': 'http://django:5000',
'/swagger': 'http://django:5000',
'/redoc': 'http://django:5000',
'/proxy': 'http://django:5000',
'/tempStorage': 'http://django:5000',
'/frontend-config.js': 'http://localhost:5000',
'/api': 'http://localhost:5000',
'/accounts': 'http://localhost:5000',
'/account-confirm-email': 'http://localhost:5000',
'/swagger': 'http://localhost:5000',
'/redoc': 'http://localhost:5000',
'/proxy': 'http://localhost:5000',
'/tempStorage': 'http://localhost:5000',
'/login': 'http://localhost:5000',
'/complete': 'http://localhost:5000',
},
},
build: {
Expand Down
71 changes: 0 additions & 71 deletions metagrid_configs/.local_config

This file was deleted.

91 changes: 0 additions & 91 deletions metagrid_configs/metagrid_config.tmpl

This file was deleted.

0 comments on commit a10c8a8

Please sign in to comment.