Skip to content

Add per-request identity (P2) and OIDC authentication (P3) - #109

Merged
vijay-tylertech merged 1 commit into
mainfrom
feat/fkb-auth-identity
Sep 13, 2026
Merged

vijay-tylertech merged 1 commit into
mainfrom
feat/fkb-auth-identity

Conversation

@vijay-tylertech

Copy link
Copy Markdown
Contributor

Summary

  • P2: ME module global -> threading.local() + current_login(). Fixes the mis-attribution risk of ThreadingHTTPServer sharing one identity across concurrent hosted visitors. Laptop/CLI path (AUTH_ENABLED off) is unaffected - current_login() resolves to the same _STARTUP_ME ME used to be.
  • P3: OIDC Authorization Code + PKCE, mirroring ops-tools' own login gate. Off unless FKB_OIDC_CLIENT_ID is set. FKB_IDENTITY_MAP (host-side, outside git) bridges OIDC email -> GitHub login for this app's existing contributors.json/agent-owners.json authorization. Unmapped or non-contributor logins get "Not authorized," never a silent fallback.
  • Corrected is_admin()'s docstring (was laptop-only-true), fixed auto_commit_message()'s identity precedence for hosted PR titles, added /healthz.

Test plan

  • python3 scripts/check_auth_identity.py - unset-vs-hosted-gate over real HTTP, plus session sign/tamper and thread-isolation checks (two concurrent "requests" never see each other's identity)
  • check_base_path.py, check_write_boundary.py, check_ui_js.py, check_admin_paths.py, review_status.py --check - all still pass

P2 - the sharpest end of hosting this app: ME was a module-level global,
resolved once at process startup from `gh api user`. Hosted, that is one
identity shared by every concurrent visitor on ThreadingHTTPServer, so a
save could be silently mis-attributed in git to whoever else's request
last touched the global. Replaced with threading.local() (_LOCAL) and a
current_login() reader; do_GET/do_POST resolve and set it once per
request via _set_current_login(). Laptop/CLI path unchanged: unset
AUTH_ENABLED means current_login() always resolves to _STARTUP_ME, the
same identity main() has always resolved once at startup.

P3 - OIDC Authorization Code + PKCE, deliberately mirroring ops-tools'
own login gate pattern (operator's instruction): same discovery-doc/
token/userinfo flow, same httpOnly+Secure+SameSite signed session
cookie over an in-memory store, same welcome/not-authorized pre-auth
pages. Entirely off unless FKB_OIDC_CLIENT_ID is set.

The identity bridge: OIDC gives an email; this app's authorization
(contributors.json, agent-owners.json) is keyed on a GitHub username.
FKB_IDENTITY_MAP (host-side JSON file, outside git) maps casefolded
email -> GitHub login. An authenticated user who is unmapped, or whose
mapped login isn't a real contributor, gets "Not authorized" - never a
silent fallback to an admin/default identity.

Also: corrected is_admin()'s docstring, which claimed hiding the UI
"does not hide the data" - true on a laptop (everyone has the full
checkout), false for a hosted visitor whose only access IS the app.
Fixed auto_commit_message()'s precedence so hosted PR titles carry the
real per-request reviewer instead of the shared container-wide git
identity, restoring the "several reviewers" readability the function's
own docstring describes. Added /healthz - reachable with no session,
minimum surface, same pattern as ops-tools' own.

New scripts/check_auth_identity.py: unset-vs-hosted behavior over real
HTTP, plus session/cookie-tamper/thread-isolation checks in isolation
(a live identity gateway isn't available to a CI check).
@vijay-tylertech
vijay-tylertech requested a review from a team as a code owner September 13, 2026 18:47
@vijay-tylertech
vijay-tylertech merged commit b8b3b53 into main Sep 13, 2026
1 check passed
@vijay-tylertech
vijay-tylertech deleted the feat/fkb-auth-identity branch September 13, 2026 18:47
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.

1 participant