Repository navigation
feat(flutter): pin the SEP-10 challenge checks to the live server before the wallet prompt (#136) - #176
Conversation
…ore the wallet prompt (#136) Ports what the #174 draft added over main's sign-in (#149), onto main's WalletPort.signChallenge(SignInChallenge): - assertSep10Challenge now also requires a web_auth_domain operation from the server, checks its value when the app knows it, and verifies the server's own signature (the transaction source, on Testnet) before Freighter is prompted. Before, a challenge with no server signature was signed. - SignInChallenge, WalletSession and readAuthConfig carry webAuthDomain. readAuthConfig takes build-time pins (PULS3_AUTH_SERVER_SIGNING_KEY, PULS3_AUTH_HOME_DOMAIN, PULS3_AUTH_WEB_AUTH_DOMAIN) that win over config.json, because the static Pages build has no server-published auth block, so today it pins nothing. - cloudflare-pages-build.sh passes the pins as dart-defines, fails when PULS3_HIRE=server is missing any of them, and refuses a server key that is not a public G... address without echoing it. - README (Deploy) and .env.example list the three Pages variables and the values of the deployed server. The #174 config.json pinned GDVEU3..., puls3.app and auth.puls3.app; the live server signs with GBEEL... and uses puls3-hub-on-stellar.api.serverpod.space for both domains, so those pins would refuse every real challenge. They are not carried over. Tests: signed challenge with the pinned web_auth_domain; refused without web_auth_domain, with another web_auth_domain, unsigned, and signed by another key; pins over config.json; Pages build pins and fail-closed cases. Refs #136
Deploying puls3 with
|
| Latest commit: |
8737e30
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7460860f.puls3-4lw.pages.dev |
| Branch Preview URL: | https://feat-136-pin-sep10-challenge.puls3-4lw.pages.dev |
moises-cisneros
left a comment
There was a problem hiding this comment.
Approved. Porting only what #174 checked and main did not, instead of rebasing a second parallel implementation, was the right call, and the live-server probe with the old pins being refused is good evidence.
I read the diff: the web_auth_domain presence and value checks and the server-signature check run before the wallet prompt, pins win over config.json only when non-blank, and the Pages script fails closed without echoing a bad key.
One nit, not blocking: in app_config.dart the new authConfigOverrides block was inserted between the resolveApiUrl doc comment ("Returns the Serverpod API URL...") and resolveApiUrl itself. That comment now sits on top of the pins and resolveApiUrl has none. Moving the pins above that doc fixes it.
Reminder for whoever merges: until the four Pages variables are set (#31 step 1), the public app still runs the demo hire.
Refs #136. Replaces the rebase of #174 from the handoff.
Why not a rebase of #174
mainalready has the app half of #136 through #149:WalletPort.signChallenge(SignInChallenge)with SEP-10 checks,WalletSessionreused per wallet,readAuthConfig, and sign-in beforecreateHire. Rebasing #174's four commits would add a second parallel implementation (Sep10ChallengeCheck,AuthConfig, another wallet session).Its
config.jsonalso pins values the live server does not use. A challenge taken from https://puls3-hub-on-stellar.api.serverpod.space today has these values:GDVEU3…ZA57GBEELNIKCJBWCVR4KYEP4LTLXWGD5MOSLRF32CHFULLMPGNTKBBKHOEGpuls3.apppuls3-hub-on-stellar.api.serverpod.spaceweb_auth_domainauth.puls3.apppuls3-hub-on-stellar.api.serverpod.spaceWith the #174 pins, the live server's challenges would always be refused. This PR ports only what #174 checked that
maindoes not.What changes
assertSep10Challenge(run before Freighter is prompted) now also:web_auth_domainoperation from the server;webAuthDomainwhen the app has one;Before this PR, a challenge without the server's signature was signed.
Pins for static builds.
readAuthConfigacceptsPULS3_AUTH_SERVER_SIGNING_KEY,PULS3_AUTH_HOME_DOMAINandPULS3_AUTH_WEB_AUTH_DOMAINas dart-defines, and they win overconfig.json. Pages has no server-publishedauthblock, so the public app currently pins nothing.SignInChallenge,WalletSessionandmain.dartpasswebAuthDomainthrough.scripts/cloudflare-pages-build.sh:PULS3_HIRE=server, fails before cloning Flutter if any pin is missing;G…address, without echoing it.Docs. The
puls3_server/README.mdDeploy section and.env.examplelist the three Pages variables and the values of the deployed server.Needed in the Pages project (Cloudflare access, #31 step 1)
Verification
New tests:
web_auth_domainis signed;web_auth_domain, anotherweb_auth_domain, unsigned, signed by another key;config.json, and blank pins do not;Against the live server: a temporary, uncommitted probe ran the app's own
WalletSessionandassertSep10Challengeagainst https://puls3-hub-on-stellar.api.serverpod.space. It signed with a throwaway testnet key instead of Freighter.verifyChallengereturns a session (walletGB4NGRMKS2PPGHWWR6BMNAO36HTY7L2JF7ZESVPEASLC3JNQWV6AEZLL).Not done yet: the run with a real Freighter wallet on the public app. It needs the Pages rebuild with the variables above.