Skip to content

fix(bff): require UPDATE in the pending-login managed-schema check - #118

Merged
ovander merged 2 commits into
mainfrom
fix/pending-login-update-grant
Oct 11, 2026
Merged

ovander merged 2 commits into
mainfrom
fix/pending-login-update-grant

Conversation

@ovander

@ovander ovander commented Oct 10, 2026

Copy link
Copy Markdown
Owner

What and why

PostgresPendingLoginStore.Put is an INSERT … ON CONFLICT (state) DO UPDATE, which needs the UPDATE privilege on the table. But WithPendingLoginManagedSchema's start-up check verified only SELECT, INSERT and DELETE (a slip from #111). A role granted exactly those three passed the check, then failed every sign-in at Put. This was found while moving the monitoring console's BFF to the managed schema, and confirmed in psql.

  • The check now also requires UPDATE, as the session store's check already does.
  • The doc comment lists all four privileges and says why.

How it was tested

  • New TestPostgresPendingLoginStore_ManagedSchemaNeedsUpdate:

    • uses a least-privilege role holding SELECT, INSERT, DELETE;
    • on a non-superuser it revokes UPDATE instead;
    • expects a start-up error naming UPDATE.
  • Fails without the fix, passes with it. Run against a local Postgres 16 with TEST_DATABASE_URL set.

  • go mod tidy && git diff --exit-code go.sum leaves go.sum unchanged

  • go build ./... passes

  • go vet ./... passes

  • go test -race -count=1 -timeout=120s ./... passes

  • golangci-lint run ./... (v2.14.0) reports no issue

  • govulncheck ./...: not run locally (vuln.go.dev is blocked here); CI runs it. No dependency change.

  • A line is added under ## [Unreleased] in CHANGELOG.md (### Fixed)

Compatibility

  • Exported-API change: no.
  • Behaviour change for existing callers:
    • With WithPendingLoginManagedSchema(), a role without UPDATE is now refused at start-up instead of failing at the first sign-in.
    • Such a configuration could not sign anyone in, so no working caller breaks.
  • Breaking change: none.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA


Generated by Claude Code

PostgresPendingLoginStore.Put is an INSERT ... ON CONFLICT DO UPDATE,
which needs UPDATE on the table, but WithPendingLoginManagedSchema's
start-up check verified only SELECT, INSERT and DELETE. A role granted
exactly those passed the check and then failed every sign-in. The check
now names UPDATE too, and the doc comment lists all four privileges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
Resolve the CHANGELOG conflict with #117: keep both Unreleased entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
@ovander
ovander merged commit 7b6688e into main Oct 11, 2026
4 checks passed
ovander pushed a commit that referenced this pull request Oct 11, 2026
Resolve the CHANGELOG conflict with #118: the conformance entry stays
under Added, the pending-login fix under Fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
ovander pushed a commit that referenced this pull request Oct 11, 2026
Moves [Unreleased] under [1.26.0] - 2026-10-11 (#117 scopes, #118 pending-login UPDATE check, #119 conformance suite), updates the compare links and the README install snippet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
@ovander ovander mentioned this pull request Oct 11, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants