3.9 KiB
3.9 KiB
TODO
Auth
Mobile login with Keycloak (phase 5)
The web app logs in with Keycloak; the mobile app still uses the legacy ?userKey= login.
- Add a
mancala-mobilepublic client toapps/keycloak/realm/mancala-realm.json(PKCE S256, redirectcom.mancala_mobile://callback) and toKEYCLOAK_CLIENT_IDSfor the backend - Add
react-native-app-authwith the redirect scheme set up for Android and iOS - Log in as a guest on first launch (
guest=true), withoffline_access; keep tokens in MMKV - Connect with
rtmt.connectWebSocket(url, getToken)instead of?userKey=(apps/mobile/src/App.tsx) and callreauthenticateafter refreshing the token - Log in / sign up / log out in the app, player names on the game screen (
getPlayerDisplayNamein core) - Decide whether guests may skip the browser tab on first launch (would need a custom grant type in the Keycloak extension)
- Delete the unused copy of the WebSocket client in
apps/mobile/src/rtmt - Test on a device
After the mobile release
- Turn off
LEGACY_USERKEY_AUTHonce old app versions are no longer in use; this also removes/register
Later
- Let guests turn their guest user into an account without changing identity (Keycloak required action)
- Stats and game history for logged in users (needs a database)
- Social logins (Keycloak identity providers)
- Restrict the Keycloak admin console in production
Deployment
- Build the backend and frontend images from the repo root in CI:
docker build -f apps/backend/Dockerfile .anddocker build -f apps/frontend/Dockerfile . - Pass
--build-arg KEYCLOAK_URL=https://auth.playmancala.appwhen building the frontend image - Deploy Keycloak (
apps/.envwithKEYCLOAK_DB_PASSWORD,KEYCLOAK_ADMIN_PASSWORD,KEYCLOAK_HOSTNAME=https://auth.playmancala.app) and reload nginx with the newauth.playmancala.appblock - Deploy the backend before the web app; the new web app needs token auth on the server
Security
- Move the Android signing passwords out of
apps/mobile/release_android.sh(committed inbb1c750) into~/.gradle/gradle.propertiesor environment variables, and consider resetting the upload key - Add
apps/mobile/mancala-upload-key.jksto.gitignore(onlyandroid/app/mancala-upload-key.jksis ignored) - Validate moves before running them instead of treating every invalid move as a crash: each one writes a
file to
crashes/and is broadcast to the players (GameManager.onGameError)
Bugs
GameStoreImpl.getSpeactatingGameIdsByUserloops withfor...inover an iterator, so it never finds anything and spectators are never removed on disconnect; usefor...of- Finished and abandoned games are never removed from
gameStore(deleteGameonly removes the user mappings), so they stay in memory until restart PitAnimator.animatePit:previousPitIndex > 0should be>= 0; a one-stone move from pit 0 does not empty that pit during the animationPitAnimator.disposeremoves a newly bound function, so the theme listener is never removed- Sowing puts stones into the opponent's store; check against the intended Mangala rules and add a test
MatchMaker.joindoes not check whether the player is already in a gameGameManager.startGamesends the connection info twiceonGameErrorbroadcasts anError, which serializes to{}
Maintenance
- The web and mobile apps duplicate components and stores; move shared code into
packages/core - Mixed lockfiles:
packages/*andapps/mobilehave bothyarn.lockandpackage-lock.json - Align TypeScript and Jest versions across packages
- Tests for
GameManager,MatchMakerandPitAnimator - CI that runs the tests
- Pre-existing type errors: 4 in the frontend, 11 in mobile; the frontend has no
tsconfig.json, so nothing type-checks it