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

SW-183: move auth to backend and use jwt for protected routes #12

Merged
merged 22 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
25 changes: 25 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
# connection details for this service
CLIENT_PORT=3000
CLIENT_URL=http://localhost:3000

BACKEND_PORT=3001
BACKEND_URL=http://localhost:3001

SESSION_SECRET=
JWT_SECRET=
JWT_EXPIRES_IN=

# rate limiting
RATE_LIMIT_WINDOW_MS=15*60*1000
RATE_LIMIT_MAX_REQ=100

# app database
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE=statswales-backend
DB_SSL=false

# storage providers
AZURE_DATALAKE_STORAGE_ACCOUNT_NAME=
AZURE_DATALAKE_STORAGE_ACCOUNT_KEY=
AZURE_DATALAKE_STORAGE_DIRECTORY_NAME=

AZURE_BLOB_STORAGE_ACCOUNT_NAME=
AZURE_BLOB_STORAGE_ACCOUNT_KEY=
AZURE_BLOB_STORAGE_CONTAINER_NAME=

# authentication providers
AUTH_PROVIDERS=google,onelogin

ONELOGIN_URL=https://oidc.integration.account.gov.uk
ONELOGIN_CLIENT_ID=
ONELOGIN_CLIENT_SECRET=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"no-console": 0,
"no-process-env": 0,
"no-inline-comments": 0,
"line-comment-position": 0
"line-comment-position": 0,
"no-warning-comments": 1
},
"globals": {
"NodeJS": true
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ jobs:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

services:
# postgres config should match the env vars set in test/helpers/jest-setup.ts
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: statswales-backend-test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5433:5432
wheelsandcogs marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -29,5 +45,5 @@ jobs:
- run: npm ci
- run: npm run prettier:ci
- run: npm run lint:ci
- run: npm run build --if-present
- run: npm run build
- run: npm run test:ci
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ yarn.lock

# Ignore local db volume
.docker/postgres/data

# Ignore certs
certs/*
j-maynard marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ Rollback the most recent migration:
npm run migration:revert
```

Generate a new migration file after updating the entities (this does not execute the migration):

```bash
npm run migration:generate -- ./src/migration/<name>
```

e.g.
```bash
npm run migration:generate -- ./src/migration/initial-schema
```

## Deploying the service

Expand Down
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
services:
postgres:
db-dev:
image: postgres:latest
ports:
- "5432:5432"
Expand All @@ -9,3 +9,12 @@ services:
POSTGRES_DB: statswales-backend
volumes:
- .docker/postgres/data:/var/lib/postgresql/data

db-test:
image: postgres:latest
ports:
- "5433:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: statswales-backend-test
4 changes: 3 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
coverageDirectory: './coverage',
collectCoverage: true,
coverageReporters: ['cobertura', 'lcov', 'html', 'text'],
coveragePathIgnorePatterns: ['/node_modules/', '/test/', '/src/controllers/datalake.ts']
coveragePathIgnorePatterns: ['/node_modules/', '/test/', '/src/controllers/datalake.ts'],
setupFiles: ['<rootDir>/test/helpers/jest-setup.ts'],
maxWorkers: 1 // TODO: temporary solution to test parallelism issue

Check warning on line 13 in jest.config.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected 'todo' comment: 'TODO: temporary solution to test...'
};

export default config;
Loading
Loading