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

Add user interface #56

Merged
merged 18 commits into from
Oct 16, 2024
Merged

Add user interface #56

merged 18 commits into from
Oct 16, 2024

Conversation

cswaney
Copy link
Member

@cswaney cswaney commented Oct 15, 2024

The application now serves pre-built HTML webpages in addition to the application endpoints. All resources required to serve the UI are stored in src/build. The build directory should be a copy of the optimized build generated by running rpm run build on the UI repository.

This PR also introduces token-based authentication via custom middleware. Authentication can be enabled or disabled at start-up using the BLACKFISH_DEV_MODE environment variable (set to 0 to require authentication). With authentication enabled, protected pages and endpoints require the user to enter a randomly generated token one time.

Closes #54, #53, #47, and #50.

Add routes to serve each page from the UI build.
Latest Litestar includes `SecretString` type.
Pages are protected by custom auth middleware and endpoints are protected by an auth "guard". At start up, we generate a random authorization token and print it to the console. To log in, users must provide the token to the `login` endpoint. In the UI, this can be accomplished with a post `fetch` request setting `redirect` to "follow" and manually handling the redirect:

```javascript
if (resp.redirected) {
  window.location.href = resp.url;
}
```

We use built-in cookie-based session middleware to keep track of whether users are logged in or not. A user is authenticated if their request contains a session with `token=AUTH_TOKEN`.

In `DEV_MODE`, use secret token "test" to authorize.
This commit relocates `app` from `__init__.py` to `asgi.py`. For a minimal application, `__init__.py` is a reasonable location (and one of the locations where Litestar automatically checks for an `app`), but for a more complex application where we are importing objects from `src/app`, this location becomes problematic.
Fixes volume mount and image path.
Forwards port and uses service `name` instead of `job_id`.
@cswaney cswaney merged commit bb75f0a into dev Oct 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant