@mastra/auth-okta 0.2.2-alpha.0 → 0.2.2-alpha.1

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 +11 -180
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,206 +1,37 @@
1
1
  # @mastra/auth-okta
2
2
 
3
- Okta integration for Mastra, providing RBAC based on Okta groups and optional JWT authentication.
4
-
5
- ## Features
6
-
7
- - 🔐 **RBAC Provider** - Map Okta groups to Mastra permissions
8
- - 🔑 **Auth Provider** - JWT token verification using Okta's JWKS
9
- - 🔄 **Cross-provider support** - Use with Auth0, Clerk, or any other auth provider
10
- - ⚡ **Caching** - LRU cache for group lookups to minimize API calls
11
- - 🛡️ **Type-safe** - Full TypeScript support with strict types
3
+ `@mastra/auth-okta` integrates Okta authentication and group-based role mapping with Mastra. Use it when Okta is your identity provider or when Okta groups should control access to Mastra agents, workflows, and other resources.
12
4
 
13
5
  ## Installation
14
6
 
15
7
  ```bash
16
8
  npm install @mastra/auth-okta
17
- # or
18
- yarn add @mastra/auth-okta
19
- # or
20
- pnpm add @mastra/auth-okta
21
9
  ```
22
10
 
23
11
  ## Usage
24
12
 
25
- ### Auth0 + Okta RBAC (Recommended)
26
-
27
- Use Auth0 for authentication and Okta for role-based access control:
28
-
29
- ```typescript
30
- import { Mastra } from '@mastra/core/mastra';
31
- import { MastraAuthAuth0 } from '@mastra/auth-auth0';
32
- import { MastraRBACOkta } from '@mastra/auth-okta';
33
-
34
- const mastra = new Mastra({
35
- server: {
36
- auth: new MastraAuthAuth0(),
37
- rbac: new MastraRBACOkta({
38
- // Extract Okta user ID from Auth0 user metadata
39
- getUserId: user => user.metadata?.oktaUserId || user.email,
40
- roleMapping: {
41
- Engineering: ['agents:*', 'workflows:*'],
42
- Product: ['agents:read', 'workflows:read'],
43
- Admin: ['*'],
44
- _default: [], // Users with unmapped groups get no permissions
45
- },
46
- }),
47
- },
48
- });
49
- ```
50
-
51
- ### Full Okta Setup
52
-
53
- For complete Okta authentication + RBAC:
13
+ Set `OKTA_DOMAIN`, `OKTA_CLIENT_ID`, `OKTA_CLIENT_SECRET`, `OKTA_REDIRECT_URI`, and `OKTA_COOKIE_PASSWORD` before starting Mastra.
54
14
 
55
15
  ```typescript
56
16
  import { Mastra } from '@mastra/core/mastra';
57
- import { MastraAuthOkta, MastraRBACOkta } from '@mastra/auth-okta';
17
+ import { MastraAuthOkta } from '@mastra/auth-okta';
58
18
 
59
- const mastra = new Mastra({
19
+ export const mastra = new Mastra({
60
20
  server: {
61
21
  auth: new MastraAuthOkta(),
62
- rbac: new MastraRBACOkta({
63
- roleMapping: {
64
- Admin: ['*'],
65
- Member: ['agents:read', 'workflows:*'],
66
- _default: [],
67
- },
68
- }),
69
22
  },
70
23
  });
71
24
  ```
72
25
 
73
- ## Configuration
74
-
75
- ### Environment Variables
76
-
77
- | Variable | Description | Required |
78
- | ---------------------- | ----------------------------------------- | -------------------------------------------------- |
79
- | `OKTA_DOMAIN` | Okta domain (e.g., `dev-123456.okta.com`) | Yes |
80
- | `OKTA_CLIENT_ID` | OAuth client ID | For auth only |
81
- | `OKTA_CLIENT_SECRET` | OAuth client secret | For auth only |
82
- | `OKTA_REDIRECT_URI` | OAuth redirect URI for SSO callback | For auth only |
83
- | `OKTA_ISSUER` | Token issuer URL | No (defaults to `https://{domain}/oauth2/default`) |
84
- | `OKTA_AUDIENCE` | Expected `aud` claim on bearer tokens | No (defaults to `OKTA_CLIENT_ID`) |
85
- | `OKTA_COOKIE_PASSWORD` | Session encryption key (min 32 chars) | No (auto-generated if omitted; set for production) |
86
- | `OKTA_API_TOKEN` | API token for management SDK | For RBAC only |
87
-
88
- ### MastraAuthOkta Options
89
-
90
- ```typescript
91
- interface MastraAuthOktaOptions {
92
- domain?: string; // Okta domain (or OKTA_DOMAIN env var)
93
- clientId?: string; // OAuth client ID (or OKTA_CLIENT_ID)
94
- clientSecret?: string; // OAuth client secret (or OKTA_CLIENT_SECRET)
95
- redirectUri?: string; // SSO callback URI (or OKTA_REDIRECT_URI)
96
- issuer?: string; // Token issuer URL (or OKTA_ISSUER)
97
- audience?: string | string[]; // Expected bearer-token `aud` (or OKTA_AUDIENCE; defaults to clientId)
98
- scopes?: string[]; // OAuth scopes (default: ['openid', 'profile', 'email', 'groups'])
99
- name?: string; // Provider name (default: 'okta')
100
- session?: {
101
- cookieName?: string; // Cookie name (default: 'okta_session')
102
- cookieMaxAge?: number; // Cookie max age in seconds (default: 86400)
103
- cookiePassword?: string; // Encryption key, min 32 chars (or OKTA_COOKIE_PASSWORD)
104
- secureCookies?: boolean; // Set Secure flag (default: auto-detect from NODE_ENV)
105
- };
106
- }
107
- ```
108
-
109
- ### MastraRBACOkta Options
110
-
111
- ```typescript
112
- interface MastraRBACOktaOptions {
113
- domain?: string; // Okta domain
114
- apiToken?: string; // API token for group fetching
115
-
116
- // Map Okta groups to Mastra permissions
117
- roleMapping: {
118
- [groupName: string]: string[]; // e.g., 'Admin': ['*']
119
- };
120
-
121
- // Extract Okta user ID from any user object (for cross-provider use)
122
- getUserId?: (user: unknown) => string | undefined;
123
-
124
- // Cache configuration
125
- cache?: {
126
- maxSize?: number; // Max users to cache (default: 1000)
127
- ttlMs?: number; // Cache TTL in ms (default: 60000)
128
- };
129
- }
130
- ```
131
-
132
- ## Role Mapping
133
-
134
- The `roleMapping` configuration maps Okta group names to Mastra permission patterns:
135
-
136
- ```typescript
137
- roleMapping: {
138
- // Users in 'Engineering' group get full access to agents and workflows
139
- 'Engineering': ['agents:*', 'workflows:*'],
140
-
141
- // Users in 'Product' group get read-only access
142
- 'Product': ['agents:read', 'workflows:read'],
143
-
144
- // Users in 'Admin' group get full access to everything
145
- 'Admin': ['*'],
146
-
147
- // Special '_default' key: permissions for users with unmapped groups
148
- '_default': [],
149
- }
150
- ```
151
-
152
- ### Permission Patterns
153
-
154
- - `*` - Full access to all resources
155
- - `agents:*` - Full access to agents
156
- - `agents:read` - Read-only access to agents
157
- - `workflows:create` - Create workflows only
158
-
159
- ## Cross-Provider Support
160
-
161
- When using a different auth provider (Auth0, Clerk, etc.) with Okta RBAC, you need to link users between systems. The `getUserId` option allows you to extract the Okta user ID from any user object:
162
-
163
- ```typescript
164
- new MastraRBACOkta({
165
- // Extract Okta user ID from Auth0 user's app_metadata
166
- getUserId: (user) => {
167
- return user.metadata?.oktaUserId || user.email;
168
- },
169
- roleMapping: { ... },
170
- })
171
- ```
172
-
173
- ### Linking Users
174
-
175
- To link Auth0 users to Okta:
176
-
177
- 1. Store the Okta user ID in Auth0's `app_metadata`
178
- 2. Configure `getUserId` to extract it
179
- 3. Mastra will use this ID to fetch groups from Okta
180
-
181
- ## API
182
-
183
- ### MastraRBACOkta
26
+ ## Documentation
184
27
 
185
- | Method | Description |
186
- | -------------------------------------- | ------------------------------------ |
187
- | `getRoles(user)` | Get user's Okta groups |
188
- | `hasRole(user, role)` | Check if user has a specific group |
189
- | `getPermissions(user)` | Get resolved permissions from groups |
190
- | `hasPermission(user, permission)` | Check if user has a permission |
191
- | `hasAllPermissions(user, permissions)` | Check if user has all permissions |
192
- | `hasAnyPermission(user, permissions)` | Check if user has any permission |
28
+ - [Okta integration guide](https://mastra.ai/integrations/auth/okta)
29
+ - [Okta provider reference](https://mastra.ai/reference/auth/okta)
193
30
 
194
- ### MastraAuthOkta
31
+ ## Changelog
195
32
 
196
- | Method | Description |
197
- | ----------------------------------- | --------------------------- |
198
- | `authenticateToken(token, request)` | Verify JWT and return user |
199
- | `authorizeUser(user, request)` | Check if user is authorized |
33
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/auth/okta/CHANGELOG.md) for version history and release notes.
200
34
 
201
- ## Requirements
35
+ ## Support
202
36
 
203
- - Node.js 22.13.0 or later
204
- - Okta account with:
205
- - OAuth application (for authentication)
206
- - API token (for RBAC group fetching)
37
+ 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-okta",
3
- "version": "0.2.2-alpha.0",
3
+ "version": "0.2.2-alpha.1",
4
4
  "description": "Mastra Okta Auth and RBAC integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",