or3-provider-basic-auth
v0.0.7
Published
Basic-authentication provider for OR3 Chat with SSR session resolution, secure cookies, and provider-owned auth UI.
Readme
or3-provider-basic-auth
Basic-auth provider for OR3 Chat SSR mode.
This package registers:
AuthProvider(basic-auth)ProviderTokenBroker(basic-auth)- provider-owned auth UI adapter + components
Installation
bun add or3-provider-basic-authFor local development from the OR3 monorepo:
# from /Users/brendon/Documents/or3/or3-chat
bun add or3-provider-basic-auth@link:../or3-provider-basic-authRuntime registration
Add the module to your generated provider list:
export const or3ProviderModules = [
'or3-provider-basic-auth/nuxt'
] as const;Environment
Required:
AUTH_PROVIDER=basic-authOR3_BASIC_AUTH_JWT_SECRET
Optional:
OR3_BASIC_AUTH_REFRESH_SECRET(falls back toOR3_BASIC_AUTH_JWT_SECRET)OR3_BASIC_AUTH_ACCESS_TTL_SECONDS(default900)OR3_BASIC_AUTH_REFRESH_TTL_SECONDS(default2592000)OR3_BASIC_AUTH_DB_PATH(default./.data/or3-basic-auth.sqlite)OR3_BASIC_AUTH_BOOTSTRAP_EMAILOR3_BASIC_AUTH_BOOTSTRAP_PASSWORD
Strict-mode behavior:
NODE_ENV=productionorOR3_STRICT_CONFIG=truefails startup if required secrets are missing.- non-strict mode logs diagnostics and leaves provider registration disabled.
Architecture notes
- Credentials/session state is stored in a provider-owned SQLite DB.
- Canonical OR3 users/workspaces are still resolved by the selected
AuthWorkspaceStore. - In
invite_onlymode, signed-token, expiry, persisted invite state/token hash, and normalized-email validation runs before Basic Auth creates an account or session. - The selected
AuthWorkspaceStoremust support atomic invite provisioning; internal user/auth mapping, membership, and invite consumption are committed together by that provider. - Basic Auth account and initial refresh-session rows are created in one local SQLite transaction.
- Access JWTs are short-lived and validated by
basicAuthProvider.getSession(event). - Refresh tokens are rotated and hashed at rest; replay attempts revoke active sessions.
Troubleshooting
Authentication provider is not configured- Ensure
AUTH_PROVIDER=basic-authandSSR_AUTH_ENABLED=true. - Ensure
OR3_BASIC_AUTH_JWT_SECRETis set.
- Ensure
Missing OR3_BASIC_AUTH_JWT_SECRET- In strict mode (
NODE_ENV=productionorOR3_STRICT_CONFIG=true), startup fails intentionally. - Add the missing secret and restart.
- In strict mode (
Invalid credentialson known user- Verify the bootstrap account values.
- Confirm password updates were propagated after recent
change-passwordcalls.
Session expiredduring refresh- Refresh token may be revoked/rotated/replayed.
- Sign in again to create a new session chain.
Intern quick start
Implementation order used in this package:
src/runtime/server/lib/password.tssrc/runtime/server/lib/jwt.tssrc/runtime/server/db/client.tsandsrc/runtime/server/lib/session-store.tssrc/runtime/server/api/basic-auth/*.post.tssrc/runtime/server/auth/basic-auth-provider.tssrc/runtime/server/plugins/register.tssrc/runtime/components/*.client.vueandsrc/runtime/plugins/basic-auth-ui.client.tssrc/runtime/**/__tests__/*.test.ts
Scripts
bun run type-check
bun run test
bun run build