@mastra/auth-neon 0.3.2-alpha.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +12 -74
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # @mastra/auth-neon
2
2
 
3
- Mastra authentication provider for [Neon Auth](https://neon.com/docs/auth/overview), the managed authentication service built on Better Auth.
4
-
5
- Supports JWT bearer token verification via JWKS, session cookie verification, email/password sign-in/sign-up for Studio, full session management, and optional RBAC via Neon Auth's Organization plugin.
3
+ `@mastra/auth-neon` connects Neon Auth, the managed authentication service built on Better Auth, to Mastra. Use it when Neon manages your users and you need JWT, session-cookie, Studio sign-in, or organization-based authorization support.
6
4
 
7
5
  ## Installation
8
6
 
@@ -12,90 +10,30 @@ npm install @mastra/auth-neon
12
10
 
13
11
  ## Usage
14
12
 
15
- ```typescript
16
- import { MastraAuthNeon } from '@mastra/auth-neon';
17
- import { Mastra } from '@mastra/core';
18
-
19
- const auth = new MastraAuthNeon({
20
- baseUrl: process.env.NEON_AUTH_BASE_URL,
21
- });
22
-
23
- const mastra = new Mastra({
24
- server: {
25
- auth,
26
- },
27
- });
28
- ```
29
-
30
- ### With RBAC
31
-
32
- Neon Auth uses Better Auth's Organization plugin which provides `owner`, `admin`, and `member` roles. `MastraRBACNeon` maps these to Mastra permissions:
13
+ Set `NEON_AUTH_BASE_URL` before starting Mastra.
33
14
 
34
15
  ```typescript
35
- import { MastraAuthNeon, MastraRBACNeon } from '@mastra/auth-neon';
36
- import { Mastra } from '@mastra/core';
16
+ import { MastraAuthNeon } from '@mastra/auth-neon';
17
+ import { Mastra } from '@mastra/core/mastra';
37
18
 
38
- const mastra = new Mastra({
19
+ export const mastra = new Mastra({
39
20
  server: {
40
21
  auth: new MastraAuthNeon({
41
22
  baseUrl: process.env.NEON_AUTH_BASE_URL,
42
23
  }),
43
- rbac: new MastraRBACNeon({
44
- roleMapping: {
45
- owner: ['*'],
46
- admin: ['*'],
47
- member: ['agents:read', 'workflows:*'],
48
- _default: [],
49
- },
50
- }),
51
24
  },
52
25
  });
53
26
  ```
54
27
 
55
- ## Configuration
56
-
57
- ### Auth Provider
58
-
59
- | Option | Environment Variable | Description |
60
- | ------------------- | -------------------- | ----------------------------------------------------------- |
61
- | `baseUrl` | `NEON_AUTH_BASE_URL` | Neon Auth base URL (e.g., `https://your-project.neon.tech`) |
62
- | `jwksUrl` | `NEON_AUTH_JWKS_URL` | Explicit JWKS URL (overrides `baseUrl`-derived URL) |
63
- | `sessionCookieName` | — | Session cookie name (default: `neonauth.session_token`) |
64
- | `signUpEnabled` | — | Whether sign-up is allowed (default: `true`) |
65
-
66
- ### RBAC Provider
67
-
68
- | Option | Description |
69
- | ---------------- | ----------------------------------------------------------------------------------- |
70
- | `baseUrl` | Neon Auth base URL (falls back to `NEON_AUTH_BASE_URL` env var) |
71
- | `roleMapping` | Map of role slugs to Mastra permission patterns (use `_default` for unmapped roles) |
72
- | `organizationId` | Scope role lookups to a specific organization |
73
- | `cache.ttlMs` | Role cache TTL in ms (default: 60000) |
74
- | `cache.maxSize` | Max cached entries (default: 1000) |
75
- | `getUserRoles` | Custom function to extract roles from user (bypasses API calls) |
28
+ ## Documentation
76
29
 
77
- ## Authentication flow
30
+ - [Neon Auth reference](https://mastra.ai/reference/auth/neon)
31
+ - [Authentication overview](https://mastra.ai/docs/auth/overview)
78
32
 
79
- The adapter verifies tokens in two stages:
33
+ ## Changelog
80
34
 
81
- 1. **JWT verification** — Bearer JWT tokens (e.g., Neon Auth `access_token`) are verified against the JWKS endpoint at `{baseUrl}/auth/jwks`.
82
- 2. **Session verification** — If JWT verification fails, the token is treated as a session cookie and verified via the Neon Auth REST API (`GET {baseUrl}/auth/get-session`).
35
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/auth/neon/CHANGELOG.md) for version history and release notes.
83
36
 
84
- ## Implemented Interfaces
37
+ ## Support
85
38
 
86
- - `MastraAuthProvider` — Token authentication and authorization
87
- - `IUserProvider` — User awareness for Studio (getCurrentUser, getUser)
88
- - `ICredentialsProvider` — Email/password sign-in and sign-up for Studio
89
- - `ISessionProvider` — Session management (validate, refresh, destroy, cookie handling)
90
- - `IRBACProvider` (via `MastraRBACNeon`) — Role-based access control with permission mapping
91
-
92
- ## Custom Authorization
93
-
94
- ```typescript
95
- const auth = new MastraAuthNeon({
96
- baseUrl: process.env.NEON_AUTH_BASE_URL,
97
- authorizeUser: async user => {
98
- return user.jwt?.role === 'authenticated';
99
- },
100
- });
101
- ```
39
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/auth-neon",
3
- "version": "0.3.2-alpha.0",
3
+ "version": "0.3.2",
4
4
  "description": "Mastra Neon Auth integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,9 +33,9 @@
33
33
  "tsdown": "0.22.9",
34
34
  "typescript": "^7.0.2",
35
35
  "vitest": "4.1.10",
36
- "@mastra/core": "1.64.0-alpha.2",
37
- "@internal/lint": "0.0.129",
38
- "@internal/types-builder": "0.0.104"
36
+ "@internal/lint": "0.0.130",
37
+ "@internal/types-builder": "0.0.105",
38
+ "@mastra/core": "1.64.0"
39
39
  },
40
40
  "files": [
41
41
  "dist"