-
Notifications
You must be signed in to change notification settings - Fork 0
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
Remix auth #47
Remix auth #47
Changes from 33 commits
61a6f61
0a7a3b6
369d7be
b01d85a
e3af0d0
03dee09
1f49596
ddb9d99
b0b471e
c836fba
aa50570
4b7f6f2
a76ac00
3c47a56
8408972
5ae665d
e47528d
1493771
07cf174
e37c357
b68e0c7
e5b166e
13eff96
631959a
177bec2
335c13d
b9563c0
b5ffdf4
ed7aead
bfa4ed1
4a73c29
c2d6ad2
ab34407
fcc7c68
3821052
466663e
a477c35
441c87d
055807a
0cfa352
a2c50c9
5627bb4
6cfcd2e
78ec595
b63c372
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/postgres-data | ||
/node_modules | ||
/public/build | ||
.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DATABASE_URL="postgresql://postgres:postgres@localhost:5433/postgres" | ||
SESSION_SECRET=<please replace with a better secret> | ||
# For social login see docs/auth.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,12 @@ node_modules | |
|
||
/sessions | ||
/coverage | ||
|
||
/prisma/dev.db | ||
|
||
/private_key.pem | ||
/public_key.pem | ||
|
||
Caddyfile | ||
|
||
postgres-data |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,13 +6,13 @@ | |||||||||||||
|
||||||||||||||
Uses | ||||||||||||||
|
||||||||||||||
- [bartender](https://github.com/i-VRESSE/bartender) for user and job management. | ||||||||||||||
- [bartender](https://github.com/i-VRESSE/bartender) for job execution. | ||||||||||||||
- [workflow-builder](https://github.com/i-VRESSE/workflow-builder) to construct a Haddock3 workflow config file. | ||||||||||||||
- [haddock3](https://github.com/haddocking/haddock3) to compute | ||||||||||||||
|
||||||||||||||
```mermaid | ||||||||||||||
sequenceDiagram | ||||||||||||||
Web app->>+Bartender: Login | ||||||||||||||
Web app->>+Web app: Login | ||||||||||||||
Web app->>+Builder: Construct workflow config | ||||||||||||||
Builder->>+Bartender: Submit job | ||||||||||||||
Bartender->>+haddock3: Run | ||||||||||||||
|
@@ -22,8 +22,34 @@ sequenceDiagram | |||||||||||||
|
||||||||||||||
- [Remix Docs](https://remix.run/docs) | ||||||||||||||
|
||||||||||||||
## Setup | ||||||||||||||
|
||||||||||||||
```shell | ||||||||||||||
npm install | ||||||||||||||
cp .env.example .env | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a note/guideline on changing the secret? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 0cfa352 |
||||||||||||||
# Create rsa key pair for signing & verifying JWT tokens for bartender web service | ||||||||||||||
openssl genpkey -algorithm RSA -out private_key.pem \ | ||||||||||||||
-pkeyopt rsa_keygen_bits:2048 | ||||||||||||||
openssl rsa -pubout -in private_key.pem -out public_key.pem | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
## Development | ||||||||||||||
|
||||||||||||||
You need to have a Postgres database running. The easiest way is to use Docker: | ||||||||||||||
|
||||||||||||||
```sh | ||||||||||||||
npm run docker:dev | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
(Stores data in `./postgres-data`) | ||||||||||||||
(You can get a psql shell with `npm run psql:dev`) | ||||||||||||||
Comment on lines
+64
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add here how to clear the database? And remove the container? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
|
||||||||||||||
The database can be initialized with | ||||||||||||||
|
||||||||||||||
```sh | ||||||||||||||
npm run setup | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about migrations? Do I need to run this command always? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clearified in a2c50c9 |
||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
From your terminal: | ||||||||||||||
|
||||||||||||||
```sh | ||||||||||||||
|
@@ -88,13 +114,16 @@ Make sure to deploy the output of `remix build` | |||||||||||||
|
||||||||||||||
### Docker | ||||||||||||||
|
||||||||||||||
The web application can be run inside a Docker container. | ||||||||||||||
The web application can be run inside a Docker container together with all its dependent containers. | ||||||||||||||
|
||||||||||||||
Requirements: | ||||||||||||||
|
||||||||||||||
1. [bartender repo](https://github.com/i-VRESSE/bartender) to be cloned in `../bartender` directory. | ||||||||||||||
2. bartender repo should have [.env file](https://github.com/i-VRESSE/bartender/blob/main/docs/configuration.md#environment-variables) | ||||||||||||||
3. bartender repo should have a [config.yaml file](https://github.com/i-VRESSE/bartender/blob/main/docs/configuration.md#configuration-file) | ||||||||||||||
1. Private key `./private_key.pem` and public key `./public_key.pem`. | ||||||||||||||
2. `./.env` file for haddock3 web application. | ||||||||||||||
3. [bartender repo](https://github.com/i-VRESSE/bartender) to be cloned in `../bartender` directory. | ||||||||||||||
4. bartender repo should have [.env file](https://github.com/i-VRESSE/bartender/blob/main/docs/configuration.md#environment-variables) | ||||||||||||||
5. bartender repo should have a [config.yaml file](https://github.com/i-VRESSE/bartender/blob/main/docs/configuration.md#configuration-file) | ||||||||||||||
1. The `job_root_dir` key should be set to `/tmp/jobs` | ||||||||||||||
|
||||||||||||||
Build with | ||||||||||||||
|
||||||||||||||
|
@@ -110,20 +139,9 @@ docker compose up | |||||||||||||
|
||||||||||||||
Web application running at http://localhost:8080 . | ||||||||||||||
|
||||||||||||||
Create super user with | ||||||||||||||
## Authentication & authorization | ||||||||||||||
|
||||||||||||||
```sh | ||||||||||||||
# First register user in web application | ||||||||||||||
docker compose exec bartender bartender super <email> | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
## Sessions | ||||||||||||||
|
||||||||||||||
Making the login session secure requires a session secret. | ||||||||||||||
The session secret can be configured by setting the `SESSION_SECRET` environment variable. | ||||||||||||||
If not set, a hardcoded secret is used, which should not be used in production. | ||||||||||||||
|
||||||||||||||
The data of the login sessions in stored in the `./sessions` directory. | ||||||||||||||
See [docs/auth.md](docs/auth.md). | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be good to say here already that the first user is automatically admin. |
||||||||||||||
|
||||||||||||||
## Bartender web service client | ||||||||||||||
|
||||||||||||||
|
@@ -139,28 +157,27 @@ npm run generate-client | |||||||||||||
|
||||||||||||||
## Bartender web service configuration | ||||||||||||||
|
||||||||||||||
### Bartender | ||||||||||||||
|
||||||||||||||
The web application needs to know where the [Bartender web service](https://github.com/i-VRESSE/bartender) is running. | ||||||||||||||
The haddock3 web application needs to know where the [Bartender web service](https://github.com/i-VRESSE/bartender) is running. | ||||||||||||||
Configure bartender location with `BARTENDER_API_URL` environment variable. | ||||||||||||||
|
||||||||||||||
```sh | ||||||||||||||
export BARTENDER_API_URL='http://127.0.0.1:8000' | ||||||||||||||
npm start | ||||||||||||||
BARTENDER_API_URL=http://localhost:8000 | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
### Social login | ||||||||||||||
|
||||||||||||||
To enable GitHub or Orcid or EGI Check-in login the bartender web service needs following environment variables. | ||||||||||||||
The haddock3 web application must be trusted by the bartender web service using a JWT token. | ||||||||||||||
An RSA private key is used by the haddock3 web application to sign the JWT token. | ||||||||||||||
To tell the haddock3 web application where to find the private key, use the `BARTENDER_PRIVATE_KEY` environment variable. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this explananation is a bit confusing. What about:
Suggested change
|
||||||||||||||
|
||||||||||||||
```shell | ||||||||||||||
BARTENDER_GITHUB_REDIRECT_URL="http://localhost:3000/auth/github/callback" | ||||||||||||||
BARTENDER_ORCIDSANDBOX_REDIRECT_URL="http://localhost:3000/auth/orcidsandbox/callback" | ||||||||||||||
BARTENDER_ORCID_REDIRECT_URL="http://localhost:3000/auth/orcid/callback" | ||||||||||||||
BARTENDER_EGI_REDIRECT_URL="http://localhost:3000/auth/egi/callback" | ||||||||||||||
```sh | ||||||||||||||
BARTENDER_PRIVATE_KEY=private_key.pem | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
Where `http://localhost:3000` is the URL where the Remix run app is running. | ||||||||||||||
An RSA public key is used by the bartender web service to verify the JWT token. | ||||||||||||||
To tell the bartender web service where to find the public key, use the `BARTENDER_PUBLIC_KEY` environment variable. | ||||||||||||||
|
||||||||||||||
```sh | ||||||||||||||
BARTENDER_PUBLIC_KEY=public_key.pem | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
## Haddock3 application | ||||||||||||||
|
||||||||||||||
|
@@ -171,18 +188,10 @@ applications: | |||||||||||||
haddock3: | ||||||||||||||
command: haddock3 $config | ||||||||||||||
config: workflow.cfg | ||||||||||||||
allowed_roles: | ||||||||||||||
- easy | ||||||||||||||
- expert | ||||||||||||||
- guru | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
This allows the archive generated with the workflow builder to be submitted. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an explicit note here that you shouldn't be using bartender's "allowed_roles" settings? |
||||||||||||||
|
||||||||||||||
The user can only submit jobs when he/she has any of these allowed roles. | ||||||||||||||
A super user should assign a role to the user at http://localhost:3000/admin/users. | ||||||||||||||
A super user can be made through the admin page or by running `bartender super <email>` on the server | ||||||||||||||
|
||||||||||||||
## Catalogs | ||||||||||||||
|
||||||||||||||
This repo has a copy (`./app/catalogs/*.yaml`) of the [haddock3 workflow build catalogs](https://github.com/i-VRESSE/workflow-builder/tree/main/packages/haddock3_catalog/public/catalog). | ||||||||||||||
|
@@ -192,3 +201,7 @@ To fetch the latest catalogs run | |||||||||||||
```shell | ||||||||||||||
npm run catalogs | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
## Stack | ||||||||||||||
|
||||||||||||||
The tech stack is explained in [docs/stack.md](docs/stack.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe start with a note that you need to have a running instance of bartender setup before starting this? And point to the section below on how to set it up?