swarm/tournament/scripts/docker/build-server-executable.sh
Karl Ostmo 82e8ac95ad
Implement GitHub authentication (#1856)
Closes #1847.

## Demo

### Production
https://swarmgame.net/list-games.html

### Local testing
```
tournament/scripts/demo/server-native.sh
```
and

```
scripts/test/run-tests.sh swarm:test:tournament-host
```

## Authentication flow

1. Users are represented by a GitHub username (primary key) and an "authentication cookie" in the SQLite database.
2. Site prompts user to login when the client's cookie is nonexistent or does not match any user in the database.
3. GitHub flow:
    1. Clicking the "Login" link redirects user to the GitHub login page.
    2. GitHub sends a `code` to our callback URL.
    3. use that `code` to get an "access token"
    4. use the "access token" to look up the username of the person who is logging in.
    5. generate and store a new cookie in the database row for that username
    6. set the cookie value on the user's client.
4. As long as the client keeps sending the cookie value known to the server, all uploads/activity will be attributed to their GitHub username.

## New features

* Login/Logout
* All uploaded content is attributed to an authenticated GitHub user
* Separate pages for scenario lists and solution lists
* Download a solution file
2024-05-22 00:27:21 +00:00

24 lines
698 B
Bash
Executable File

#!/bin/sh -ex
# Usage:
# Intended to be invoked in Dockerfile.
#
# build-server-executable.sh <output binary location>
#
# Note that we use 'cabal' instead of 'stack' becuase
# 'stack' fails to compile the 'vty' package within the Amazon Linux docker image.
BUILD_TARGET=swarm:swarm-host-tournament
CABAL_ARGS="-j -O0 --enable-executable-static $BUILD_TARGET"
cabal build $CABAL_ARGS
#cp $(cabal list-bin $CABAL_ARGS) $1
BIN_PATH=$(cabal list-bin $CABAL_ARGS)
strip $BIN_PATH
BIN_NAME=swarm-host-tournament
TEMP_UPLOAD_BIN_NAME=$BIN_NAME.new
rsync -P $BIN_PATH lightsail:$TEMP_UPLOAD_BIN_NAME
ssh lightsail -C "mv $TEMP_UPLOAD_BIN_NAME $BIN_NAME && sudo systemctl restart swarm-tournament"