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

Implement GitHub authentication #1856

Merged
merged 7 commits into from
May 22, 2024
Merged

Implement GitHub authentication #1856

merged 7 commits into from
May 22, 2024

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented May 19, 2024

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

@kostmo kostmo force-pushed the feature/github-auth branch 3 times, most recently from 77db396 to 54f9019 Compare May 20, 2024 07:19
@kostmo kostmo marked this pull request as ready for review May 20, 2024 07:26
Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@kostmo , when you get a chance, could you take a look at #1583 and #1851 ?

@kostmo kostmo added merge me Trigger the merge process of the Pull request. and removed merge me Trigger the merge process of the Pull request. labels May 21, 2024
@kostmo kostmo force-pushed the feature/github-auth branch from 801d01a to 706d3a6 Compare May 21, 2024 23:23
@kostmo kostmo added the merge me Trigger the merge process of the Pull request. label May 22, 2024
@mergify mergify bot merged commit 82e8ac9 into main May 22, 2024
11 checks passed
@mergify mergify bot deleted the feature/github-auth branch May 22, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Login with GitHub" to swarmgame.net
2 participants