|
| 1 | +# bctf |
| 2 | + |
| 3 | +The updated website for b01lers CTF! |
| 4 | + |
| 5 | +This website was heavily inspired by [LA CTF](https://platform.lac.tf/) and the default rCTF frontend. |
| 6 | + |
| 7 | +### Running locally |
| 8 | + |
| 9 | +This is a custom Next.js frontend wrapping [rCTF](https://rctf.redpwn.net/) as a backend. To configure rCTF, edit the |
| 10 | +config files in `/conf.d` [as normal](https://rctf.redpwn.net/configuration/). In `conf.d`, |
| 11 | + |
| 12 | +- `01-ui.yaml` defines rCTF's UI config values. These values are mostly ignored by the custom frontend, but necessary |
| 13 | +for styling certain things that we don't have full control over (ex. the email template). |
| 14 | +- `02-ctf.yaml` defines metadata for the actual CTF, including divisions, start / end time, and the frontend URL. |
| 15 | +- `03-db.yaml` defines config options for rCTF's underlying databases. |
| 16 | +- `04-email.yaml` defines config options for email verification. This includes an API key so isn't committed, but an |
| 17 | +example is included in `04-email.example.yaml`. |
| 18 | +- `05-uploads.yaml` defines config options for GCS uploads. This includes a private key and service account email so |
| 19 | +isn't committed, but an example is included in `05-uploads.example.yaml`. |
| 20 | +- `06-secrets.yaml` defines secret rCTF values such as the token key. |
| 21 | + |
| 22 | +To run just the frontend, first install dependencies with |
| 23 | +```bash |
| 24 | +npm i |
| 25 | +``` |
| 26 | +In `next.config.js`, set `env.API_URL` to the public API URL of the rCTF instance, and `KLODD_URL` to the public URL of |
| 27 | +the Klodd instancer frontend: |
| 28 | +```js |
| 29 | +const nextConfig = { |
| 30 | + env: { |
| 31 | + API_BASE: 'http://ctf.b01lers.com:9000/api/v1', |
| 32 | + KLODD_URL: 'https://klodd.localhost.direct' |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | +Then, run |
| 37 | +```bash |
| 38 | +npm run dev |
| 39 | +``` |
| 40 | +to start the development server on `localhost:3000`. |
| 41 | + |
| 42 | +To start rCTF, you'll need a `.env` file in the project root exporting database credentials: |
| 43 | +```env |
| 44 | +RCTF_DATABASE_PASSWORD=... |
| 45 | +RCTF_REDIS_PASSWORD=... |
| 46 | +RCTF_GIT_REF=master |
| 47 | +``` |
| 48 | +(this file can be copied after running [rCTF's install script](https://rctf.redpwn.net/installation/)). |
| 49 | + |
| 50 | +You can then start both the rCTF backend and production frontend instance simultaneously with |
| 51 | +```bash |
| 52 | +docker-compose up -d --build |
| 53 | +``` |
| 54 | + |
| 55 | +### Configuring |
| 56 | +Further config options can be edited in `/util/config.ts`: |
| 57 | +```ts |
| 58 | +export const SOLVES_PAGE_SIZE = 10; |
| 59 | +export const SCOREBOARD_PAGE_SIZE = 100; |
| 60 | + |
| 61 | +export const AUTH_COOKIE_NAME = 'ctf_clearance'; |
| 62 | +``` |
| 63 | +- `SOLVES_PAGE_SIZE` — The number of solves to show on each page of the solves modal. |
| 64 | +- `SCOREBOARD_PAGE_SIZE` — The number of teams to show on each page of the scoreboard. |
| 65 | +- `AUTH_COOKIE_NAME` — The name of the auth token cookie. |
0 commit comments