On this page
Bind session IDs to verified memberships
- 1When an authenticated user starts a session, verify their membership in the selected organization and save the eve session ID with that organization's ID. Complete the binding before returning the ID to the client. Store a user ID too if sessions are personal within an organization.
- 2Save this as eve-session-access.test.mjs and run node --test eve-session-access.test.mjs. It models a team-shared session. Pass the verified principal and server-loaded binding in the app, and replace the fixture lookup with your current membership query.
Code import assert from 'node:assert/strict'; import { test } from 'node:test'; async function mayUseSession({ principal, activeOrgId, binding, isMember }) { if (!principal?.userId || !binding || binding.orgId !== activeOrgId) { return false; } return await isMember(principal.userId, binding.orgId) === true; } test('a bound session requires current membership in the active organization', async () => { const members = new Set(['sam:acme']); const access = { principal: { userId: 'sam' }, activeOrgId: 'acme', binding: { orgId: 'acme' }, isMember: async (userId, orgId) => members.has(userId + ':' + orgId), }; assert.equal(await mayUseSession(access), true); assert.equal(await mayUseSession({ ...access, activeOrgId: 'other' }), false); assert.equal(await mayUseSession({ ...access, binding: null }), false); assert.equal(await mayUseSession({ ...access, principal: null }), false); members.delete('sam:acme'); assert.equal(await mayUseSession(access), false); }); - 3Put the check before forwarding follow-ups, stream connections and state-changing calls such as cancel or reset. If an app gateway enforces it, restrict the underlying eve routes to trusted callers so every user request goes through that check. Treat a requested organization ID as a selection to verify.
- 4Scope data access in tools using verified caller context and the server-side binding. On a resumed turn, ctx.session.auth.current can differ from auth.initiator. Define what a subagent or background job may do when there is no current user. For long-lived streams, decide how a membership change closes or invalidates an existing connection.
Related guides
Official docs behind this checklist
Browse all launch guides · Read resources · How to make and check your next change
FAQ for builders before launch
Can I use the session ID as proof that someone owns it?
Use the ID to look up the server-side binding. Authenticate the caller and check their current membership before streaming or accepting input.
Does Vercel OIDC make a session organization-scoped?
OIDC can authenticate the service reaching eve. The app still needs a verified user identity and an organization-specific authorization decision.