Title: [Feature]: First-party session, auth, and middleware primitives for `server` · Issue #132 · bQuery/bQuery · GitHub
Open Graph Title: [Feature]: First-party session, auth, and middleware primitives for `server` · Issue #132 · bQuery/bQuery
X Title: [Feature]: First-party session, auth, and middleware primitives for `server` · Issue #132 · bQuery/bQuery
Description: Pre-flight checklist I searched existing issues and did not find a duplicate request. I explained the problem or use case, not just the desired API. Problem or use case Beyond WebSocket sessions, server has no first-party session, authen...
Open Graph Description: Pre-flight checklist I searched existing issues and did not find a duplicate request. I explained the problem or use case, not just the desired API. Problem or use case Beyond WebSocket sessions, s...
X Description: Pre-flight checklist I searched existing issues and did not find a duplicate request. I explained the problem or use case, not just the desired API. Problem or use case Beyond WebSocket sessions, s...
Opengraph URL: https://github.com/bQuery/bQuery/issues/132
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feature]: First-party session, auth, and middleware primitives for `server`","articleBody":"**Pre-flight checklist**\n- [x] I searched existing issues and did not find a duplicate request.\n- [x] I explained the problem or use case, not just the desired API.\n\n**Problem or use case**\nBeyond WebSocket sessions, `server` has no first-party session, authentication, or composable middleware story. Every non-trivial service needs request-scoped sessions, some auth primitive, and a middleware pipeline; without them, adopters must hand-roll these or pull dependencies — which both undermines the \"batteries-included, dependency-free backend\" claim and is a blocker to `server` Stable (#131).\n\n**Proposed solution**\nAdd a small, secure-by-default middleware pipeline plus session and auth primitives: signed/encrypted cookie sessions, a pluggable session store interface (in-memory default, bring-your-own for Redis/etc. without bundling a client), CSRF protection that composes with the security module, and minimal auth helpers (credential verification hooks, route guards mirroring the router's guard ergonomics). Keep each primitive independently importable and tree-shakeable.\n\n**Possible API or UX shape**\n```ts\nimport { createApp, session, csrf, guard } from \"@bquery/bquery/server\";\n\nconst app = createApp();\napp.use(session({ secret: env.SECRET, store: memoryStore() }));\napp.use(csrf());\n\napp.route(\"GET\", \"/me\", guard(ctx =\u003e !!ctx.session.userId), ctx =\u003e {\n return ctx.renderResponse(MeView, { userId: ctx.session.userId });\n});\n```\n\n**Alternatives considered**\nDocumenting recipes for third-party session/auth libraries — contradicts the dependency-free goal and leaves security-critical code to users. A full identity provider — over-scoped; the right scope is primitives (sessions, CSRF, guards) that compose, not a turnkey auth system.\n\n**Relevant area**\n`server`\n\n**Additional context**\nShould reuse the existing security module (sanitize/Trusted Types/CSP) so the backend inherits secure-by-default behavior. Pairs naturally with form actions (#140) and file-based route actions (#149), which need server-side session context.\n","author":{"url":"https://github.com/JosunLP","@type":"Person","name":"JosunLP"},"datePublished":"2026-06-26T21:25:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/132/bQuery/issues/132"}
| 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:c3bfa3d8-d7d6-fc18-b822-b308c936574f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1B4:3C007C:37FA17:510C8E:6A4E036E |
| html-safe-nonce | 5f73a627f9803ab4d3daccc6717b38940119dba87d64d249485dd346294e9dbb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUI0OjNDMDA3QzozN0ZBMTc6NTEwQzhFOjZBNEUwMzZFIiwidmlzaXRvcl9pZCI6Ijc5OTc2OTY3NjQ0NDk1MjI1NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1be55a7265463f21ea96e0696dd5b7669eeab4feffd716ed8baebe21ecf6959d |
| hovercard-subject-tag | issue:4755236762 |
| 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/bQuery/bQuery/132/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bfe0927fb40807c71b9473016baa50b6eb138e147149a1e709fb8c0b1773642e/bQuery/bQuery/issues/132 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bfe0927fb40807c71b9473016baa50b6eb138e147149a1e709fb8c0b1773642e/bQuery/bQuery/issues/132 |
| og:image:alt | Pre-flight checklist I searched existing issues and did not find a duplicate request. I explained the problem or use case, not just the desired API. Problem or use case Beyond WebSocket sessions, s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JosunLP |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| turbo-cache-control | no-preview |
| go-import | github.com/bQuery/bQuery git https://github.com/bQuery/bQuery.git |
| octolytics-dimension-user_id | 256381806 |
| octolytics-dimension-user_login | bQuery |
| octolytics-dimension-repository_id | 1139284244 |
| octolytics-dimension-repository_nwo | bQuery/bQuery |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1139284244 |
| octolytics-dimension-repository_network_root_nwo | bQuery/bQuery |
| 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 | 52bde38e24398476f8eb1e0760c81346c6a00812 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width