Title: Local auth short-circuit makes sign-in, sign-out and multi-user paths untestable · Issue #208 · vpython/glowscript · GitHub
Open Graph Title: Local auth short-circuit makes sign-in, sign-out and multi-user paths untestable · Issue #208 · vpython/glowscript
X Title: Local auth short-circuit makes sign-in, sign-out and multi-user paths untestable · Issue #208 · vpython/glowscript
Description: Summary Local runs cannot exercise authentication at all, and that removes a large slice of the app from testing. ide/auth.py short-circuits identity whenever the server runs locally: def is_logged_in(): return ('user' in session) or (ro...
Open Graph Description: Summary Local runs cannot exercise authentication at all, and that removes a large slice of the app from testing. ide/auth.py short-circuits identity whenever the server runs locally: def is_logged...
X Description: Summary Local runs cannot exercise authentication at all, and that removes a large slice of the app from testing. ide/auth.py short-circuits identity whenever the server runs locally: def is_logged...
Opengraph URL: https://github.com/vpython/glowscript/issues/208
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Local auth short-circuit makes sign-in, sign-out and multi-user paths untestable","articleBody":"## Summary\n\nLocal runs cannot exercise authentication at all, and that removes a large slice of the app from testing. `ide/auth.py` short-circuits identity whenever the server runs locally:\n\n```python\ndef is_logged_in():\n return ('user' in session) or (routes.is_running_locally())\n\ndef get_user_info():\n if routes.is_running_locally():\n return {'email': 'localuser@local.host'}\n return session.get('user') or {}\n```\n\nRunning locally you are **always** signed in as `localuser@local.host`. You cannot be anonymous, and you cannot be a *second* user.\n\n## What that costs, concretely\n\n* **Anonymous state does not exist locally.** The sign-in link, the `not_logged_in` API state, and any \"must be signed in\" guard cannot be tested. Three e2e tests had to be skipped for precisely this (#207) — they now skip locally and only run against a deployed server.\n* **Only one identity exists.** Anything involving two users — sharing a program, another user's folder, permission boundaries — is untestable locally.\n* **Local diverges from production at the auth layer**, which is the layer where divergence is most expensive to discover late.\n\nThe three skipped tests are just the visible symptom; the untested surface is much larger.\n\n## The fix is configuration, not a special case\n\nAuth is **raw Google OIDC through Authlib**, driven by discovery:\n\n```python\nCONF_URL = 'https://accounts.google.com/.well-known/openid-configuration'\noauth.register(..., server_metadata_url=CONF_URL, client_kwargs={'scope': 'openid email profile'})\n```\n\nBecause it is standard OIDC discovery, a local **mock OIDC provider** (mock-oauth2-server, Dex, oauth2-mock-server — all run happily in Docker beside the datastore emulator) can serve that role. Point `CONF_URL` plus client id/secret at it for local runs and the *real* OAuth code path executes locally, with real sessions, sign-out, and as many identities as the tests need.\n\nAt that point the special case can simply be **deleted**: `is_logged_in()` and `get_user_info()` become session-only, with no environment branch at all.\n\n⚠️ Worth stating because it is an easy wrong turn: the **Firebase Auth emulator is not the right tool here.** It emulates Firebase Auth, not generic OIDC. `CONF_URL` is currently a module constant, so the first concrete step is making it (and the client id/secret) configurable.\n\n## The same hack is in webvpython\n\n`webvpython/flaskHost/src/auth.py` carries it at three sites:\n\n| line | what |\n|---|---|\n| 70 | `is_logged_in()` returns true whenever local |\n| 73-74 | `get_user_info()` returns `localuser@local.host` |\n| 88 | `login()` sets `session['user'] = {'email':'local@user'}` and redirects |\n\nLine 88 is notable: it is *already* the right shape — a local login that populates the session — but the other two override it unconditionally, so it never takes effect. Whatever lands here should land there.\n\n## Done when\n\n- [ ] `CONF_URL` / client id / secret configurable per environment\n- [ ] a mock OIDC provider in the local compose setup\n- [ ] the local-mode branches removed from `is_logged_in()` and `get_user_info()`\n- [ ] the three tests skipped in #207 **run and pass locally**\n- [ ] same treatment applied to `webvpython/flaskHost/src/auth.py`\n\nDesign notes on branch `feat/local-auth-emulator` (`docs/LOCAL-AUTH-DESIGN.md`).\n","author":{"url":"https://github.com/sspickle","@type":"Person","name":"sspickle"},"datePublished":"2026-08-24T00:35:02Z","url":"https://github.com/vpython/glowscript/issues/208"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fd8d1f42-8047-5f75-5af8-1270cac52275 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B80E:20C949:6ACD2C:9199A6:6B0077C7 |
| html-safe-nonce | a02e2a04600968d2db8e6ce76b431fa8aedeb005ef3d1f563c9abdea8b575e32 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODBFOjIwQzk0OTo2QUNEMkM6OTE5OUE2OjZCMDA3N0M3IiwidmlzaXRvcl9pZCI6IjI1OTk4NjA2MTA3Nzg4MjI1OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0c207f63fc7cb0545ac1d7e9373dfdd35bf47160c936392432de5cafc281b914 |
| hovercard-subject-tag | issue:5229937660 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/vpython/glowscript/208/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ebbfc4ae93583f2855909a63dfe8666302422255db5abbfe1a170c5bed689b24/vpython/glowscript/issues/208 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ebbfc4ae93583f2855909a63dfe8666302422255db5abbfe1a170c5bed689b24/vpython/glowscript/issues/208 |
| og:image:alt | Summary Local runs cannot exercise authentication at all, and that removes a large slice of the app from testing. ide/auth.py short-circuits identity whenever the server runs locally: def is_logged... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sspickle |
| hostname | github.com |
| expected-hostname | github.com |
| None | 75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16 |
| turbo-cache-control | no-preview |
| go-import | github.com/vpython/glowscript git https://github.com/vpython/glowscript.git |
| octolytics-dimension-user_id | 1280757 |
| octolytics-dimension-user_login | vpython |
| octolytics-dimension-repository_id | 187905631 |
| octolytics-dimension-repository_nwo | vpython/glowscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 187905631 |
| octolytics-dimension-repository_network_root_nwo | vpython/glowscript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 84e563eb4b55f8fa102f325f117533cee9e3df4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width