[PR #82] Adding Google Sign-In to the Admin Web
- What changed: A Google account sign-in page for the admin web was added, along with handling for a login that is missing or has ended in the middle of use.
- Decision: The handling for an ended login is kept in one place, not repeated on each screen. A form still being filled in is not closed; only a notice is shown.
- Not verified: Whether the Google sign-in button works in a real browser has not been checked yet.
What and why
The admin web was given Google account sign-in, along with handling for the case where there is no login or the login ends in the middle of use. I requested this work, and Claude implemented it.
- New files for the sign-in page, a guard (a check that blocks screens that need a login), the shared layout, and a session-expired notice.
- The Google button loads Google’s script directly on the page. No new package was added.
- The Google login credential (ID token, a one-time proof of sign-in from Google) is sent to the server once and is not stored or logged.
Chosen approach and rejected alternatives
- Chosen: If a request in use gets a 401 (the server’s answer meaning “not signed in”), the sign-in page shows “your sign-in time has ended.” If there was no login from the start, the current address is remembered and the user is sent to the sign-in page.
- Chosen: If another request gets a 401, only the sign-in check runs again, and the guard handles the redirect. This avoids separate handling on each screen.
- Chosen: If a save gets a 401 in a window, the window is not closed. A shared notice asks the user to sign in again in a new tab.
- Rejected: Catching every 401 globally and sending the user straight to sign-in. Anything typed would be lost.
- Chosen: The address to return to after sign-in (
next) is only allowed to be a path on the same site. This prevents an open redirect (a link that sends people to another site, which attackers can abuse).
How it was checked
- 12 new tests failed at first because the files did not exist yet, and all passed after the implementation. The test code was not changed.
- The first check failed on a type error in the test file, which stopped the type check. The implementation side did not quietly edit the test; the side that wrote the test fixed it. After that, the remote check (CI) passed.
- Two reviews that read only the source code were run. The first review was done by a different model, and the final review was done by Claude Opus. The first review raised three low-level findings. The final review raised one medium-level finding (a
nextvalue that passed through to another site) and three low-level findings. Claude fixed the four from the final review and added tests for them. The three from the first review were not fixed in this PR; they were left as items to handle in a later screen task. - Not verified: Google’s official setup guide was not checked, because the work had no internet access. The options written in the plan were used as they were.
- Not verified: What happens when the Google setting value is empty, and whether the server blocks sign-in requests sent from another site. The second one needs a check on the server side.
Lessons
- When the side that wrote a test and the side that implemented the feature are different, it is better to send a wrong test back to the side that wrote it than to edit it quietly on the implementation side.
- The screens currently use only basic markup, and this post records that as it is.