@mastra/auth-okta 0.0.0-diligent-sun-20260326085941
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.
- package/CHANGELOG.md +46 -0
- package/LICENSE.md +30 -0
- package/README.md +204 -0
- package/dist/auth-provider.d.ts +120 -0
- package/dist/auth-provider.d.ts.map +1 -0
- package/dist/index.cjs +593 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +585 -0
- package/dist/index.js.map +1 -0
- package/dist/rbac-provider.d.ts +134 -0
- package/dist/rbac-provider.d.ts.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +65 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @mastra/auth-okta
|
|
2
|
+
|
|
3
|
+
## 0.0.0-diligent-sun-20260326085941
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067), [`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`7302e5c`](https://github.com/mastra-ai/mastra/commit/7302e5ce0f52d769d3d63fb0faa8a7d4089cda6d), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`86e3263`](https://github.com/mastra-ai/mastra/commit/86e326363edd12be5a5b25ccce4a39f66f7c9f50), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778)]:
|
|
8
|
+
- @mastra/core@0.0.0-diligent-sun-20260326085941
|
|
9
|
+
|
|
10
|
+
## 0.0.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- fix(auth-okta): harden security defaults and address code review feedback ([#14553](https://github.com/mastra-ai/mastra/pull/14553))
|
|
15
|
+
- Fix cache poisoning: errors in `fetchGroupsFromOkta` now propagate so the outer `.catch` evicts the entry and retries on next request
|
|
16
|
+
- Reduce cookie size: only store user claims, id_token (for logout), and expiry — access/refresh tokens are no longer stored, keeping cookies under the 4KB browser limit
|
|
17
|
+
- Add `id_token_hint` to logout URL (required by Okta)
|
|
18
|
+
- Add console.warn for auto-generated cookie password and in-memory state store in production
|
|
19
|
+
- Document missing env vars (`OKTA_CLIENT_SECRET`, `OKTA_REDIRECT_URI`, `OKTA_COOKIE_PASSWORD`) in README and examples
|
|
20
|
+
- Expand `MastraAuthOktaOptions` docs to include all fields (session config, scopes, etc.)
|
|
21
|
+
- Fix test to actually exercise `getUserId` cross-provider lookup path
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`68ed4e9`](https://github.com/mastra-ai/mastra/commit/68ed4e9f118e8646b60a6112dabe854d0ef53902), [`085c1da`](https://github.com/mastra-ai/mastra/commit/085c1daf71b55a97b8ebad26623089e40055021c), [`be37de4`](https://github.com/mastra-ai/mastra/commit/be37de4391bd1d5486ce38efacbf00ca51637262), [`7dbd611`](https://github.com/mastra-ai/mastra/commit/7dbd611a85cb1e0c0a1581c57564268cb183d86e), [`f14604c`](https://github.com/mastra-ai/mastra/commit/f14604c7ef01ba794e1a8d5c7bae5415852aacec), [`4a75e10`](https://github.com/mastra-ai/mastra/commit/4a75e106bd31c283a1b3fe74c923610dcc46415b), [`f3ce603`](https://github.com/mastra-ai/mastra/commit/f3ce603fd76180f4a5be90b6dc786d389b6b3e98), [`423aa6f`](https://github.com/mastra-ai/mastra/commit/423aa6fd12406de6a1cc6b68e463d30af1d790fb), [`f21c626`](https://github.com/mastra-ai/mastra/commit/f21c6263789903ab9720b4d11373093298e97f15), [`41aee84`](https://github.com/mastra-ai/mastra/commit/41aee84561ceebe28bad1ecba8702d92838f67f0), [`2871451`](https://github.com/mastra-ai/mastra/commit/2871451703829aefa06c4a5d6eca7fd3731222ef), [`085c1da`](https://github.com/mastra-ai/mastra/commit/085c1daf71b55a97b8ebad26623089e40055021c), [`4bb5adc`](https://github.com/mastra-ai/mastra/commit/4bb5adc05c88e3a83fe1ea5ecb9eae6e17313124), [`4bb5adc`](https://github.com/mastra-ai/mastra/commit/4bb5adc05c88e3a83fe1ea5ecb9eae6e17313124), [`e06b520`](https://github.com/mastra-ai/mastra/commit/e06b520bdd5fdef844760c5e692c7852cbc5c240), [`d3930ea`](https://github.com/mastra-ai/mastra/commit/d3930eac51c30b0ecf7eaa54bb9430758b399777), [`dd9c4e0`](https://github.com/mastra-ai/mastra/commit/dd9c4e0a47962f1413e9b72114fcad912e19a0a6)]:
|
|
24
|
+
- @mastra/core@1.16.0
|
|
25
|
+
|
|
26
|
+
## 0.0.2-alpha.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- fix(auth-okta): harden security defaults and address code review feedback ([#14553](https://github.com/mastra-ai/mastra/pull/14553))
|
|
31
|
+
- Fix cache poisoning: errors in `fetchGroupsFromOkta` now propagate so the outer `.catch` evicts the entry and retries on next request
|
|
32
|
+
- Reduce cookie size: only store user claims, id_token (for logout), and expiry — access/refresh tokens are no longer stored, keeping cookies under the 4KB browser limit
|
|
33
|
+
- Add `id_token_hint` to logout URL (required by Okta)
|
|
34
|
+
- Add console.warn for auto-generated cookie password and in-memory state store in production
|
|
35
|
+
- Document missing env vars (`OKTA_CLIENT_SECRET`, `OKTA_REDIRECT_URI`, `OKTA_COOKIE_PASSWORD`) in README and examples
|
|
36
|
+
- Expand `MastraAuthOktaOptions` docs to include all fields (session config, scopes, etc.)
|
|
37
|
+
- Fix test to actually exercise `getUserId` cross-provider lookup path
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [[`f14604c`](https://github.com/mastra-ai/mastra/commit/f14604c7ef01ba794e1a8d5c7bae5415852aacec), [`e06b520`](https://github.com/mastra-ai/mastra/commit/e06b520bdd5fdef844760c5e692c7852cbc5c240), [`dd9c4e0`](https://github.com/mastra-ai/mastra/commit/dd9c4e0a47962f1413e9b72114fcad912e19a0a6)]:
|
|
40
|
+
- @mastra/core@1.16.0-alpha.4
|
|
41
|
+
|
|
42
|
+
## 0.0.1
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Initial release with Okta RBAC and Auth integration
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
16
|
+
# Apache License 2.0
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
19
|
+
|
|
20
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
you may not use this file except in compliance with the License.
|
|
22
|
+
You may obtain a copy of the License at
|
|
23
|
+
|
|
24
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
|
|
26
|
+
Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
See the License for the specific language governing permissions and
|
|
30
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# @mastra/auth-okta
|
|
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
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @mastra/auth-okta
|
|
17
|
+
# or
|
|
18
|
+
yarn add @mastra/auth-okta
|
|
19
|
+
# or
|
|
20
|
+
pnpm add @mastra/auth-okta
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
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:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
57
|
+
import { MastraAuthOkta, MastraRBACOkta } from '@mastra/auth-okta';
|
|
58
|
+
|
|
59
|
+
const mastra = new Mastra({
|
|
60
|
+
server: {
|
|
61
|
+
auth: new MastraAuthOkta(),
|
|
62
|
+
rbac: new MastraRBACOkta({
|
|
63
|
+
roleMapping: {
|
|
64
|
+
Admin: ['*'],
|
|
65
|
+
Member: ['agents:read', 'workflows:*'],
|
|
66
|
+
_default: [],
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
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_COOKIE_PASSWORD` | Session encryption key (min 32 chars) | No (auto-generated if omitted; set for production) |
|
|
85
|
+
| `OKTA_API_TOKEN` | API token for management SDK | For RBAC only |
|
|
86
|
+
|
|
87
|
+
### MastraAuthOkta Options
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
interface MastraAuthOktaOptions {
|
|
91
|
+
domain?: string; // Okta domain (or OKTA_DOMAIN env var)
|
|
92
|
+
clientId?: string; // OAuth client ID (or OKTA_CLIENT_ID)
|
|
93
|
+
clientSecret?: string; // OAuth client secret (or OKTA_CLIENT_SECRET)
|
|
94
|
+
redirectUri?: string; // SSO callback URI (or OKTA_REDIRECT_URI)
|
|
95
|
+
issuer?: string; // Token issuer URL (or OKTA_ISSUER)
|
|
96
|
+
scopes?: string[]; // OAuth scopes (default: ['openid', 'profile', 'email', 'groups'])
|
|
97
|
+
name?: string; // Provider name (default: 'okta')
|
|
98
|
+
session?: {
|
|
99
|
+
cookieName?: string; // Cookie name (default: 'okta_session')
|
|
100
|
+
cookieMaxAge?: number; // Cookie max age in seconds (default: 86400)
|
|
101
|
+
cookiePassword?: string; // Encryption key, min 32 chars (or OKTA_COOKIE_PASSWORD)
|
|
102
|
+
secureCookies?: boolean; // Set Secure flag (default: auto-detect from NODE_ENV)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### MastraRBACOkta Options
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
interface MastraRBACOktaOptions {
|
|
111
|
+
domain?: string; // Okta domain
|
|
112
|
+
apiToken?: string; // API token for group fetching
|
|
113
|
+
|
|
114
|
+
// Map Okta groups to Mastra permissions
|
|
115
|
+
roleMapping: {
|
|
116
|
+
[groupName: string]: string[]; // e.g., 'Admin': ['*']
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// Extract Okta user ID from any user object (for cross-provider use)
|
|
120
|
+
getUserId?: (user: unknown) => string | undefined;
|
|
121
|
+
|
|
122
|
+
// Cache configuration
|
|
123
|
+
cache?: {
|
|
124
|
+
maxSize?: number; // Max users to cache (default: 1000)
|
|
125
|
+
ttlMs?: number; // Cache TTL in ms (default: 60000)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Role Mapping
|
|
131
|
+
|
|
132
|
+
The `roleMapping` configuration maps Okta group names to Mastra permission patterns:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
roleMapping: {
|
|
136
|
+
// Users in 'Engineering' group get full access to agents and workflows
|
|
137
|
+
'Engineering': ['agents:*', 'workflows:*'],
|
|
138
|
+
|
|
139
|
+
// Users in 'Product' group get read-only access
|
|
140
|
+
'Product': ['agents:read', 'workflows:read'],
|
|
141
|
+
|
|
142
|
+
// Users in 'Admin' group get full access to everything
|
|
143
|
+
'Admin': ['*'],
|
|
144
|
+
|
|
145
|
+
// Special '_default' key: permissions for users with unmapped groups
|
|
146
|
+
'_default': [],
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Permission Patterns
|
|
151
|
+
|
|
152
|
+
- `*` - Full access to all resources
|
|
153
|
+
- `agents:*` - Full access to agents
|
|
154
|
+
- `agents:read` - Read-only access to agents
|
|
155
|
+
- `workflows:create` - Create workflows only
|
|
156
|
+
|
|
157
|
+
## Cross-Provider Support
|
|
158
|
+
|
|
159
|
+
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:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
new MastraRBACOkta({
|
|
163
|
+
// Extract Okta user ID from Auth0 user's app_metadata
|
|
164
|
+
getUserId: (user) => {
|
|
165
|
+
return user.metadata?.oktaUserId || user.email;
|
|
166
|
+
},
|
|
167
|
+
roleMapping: { ... },
|
|
168
|
+
})
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Linking Users
|
|
172
|
+
|
|
173
|
+
To link Auth0 users to Okta:
|
|
174
|
+
|
|
175
|
+
1. Store the Okta user ID in Auth0's `app_metadata`
|
|
176
|
+
2. Configure `getUserId` to extract it
|
|
177
|
+
3. Mastra will use this ID to fetch groups from Okta
|
|
178
|
+
|
|
179
|
+
## API
|
|
180
|
+
|
|
181
|
+
### MastraRBACOkta
|
|
182
|
+
|
|
183
|
+
| Method | Description |
|
|
184
|
+
| -------------------------------------- | ------------------------------------ |
|
|
185
|
+
| `getRoles(user)` | Get user's Okta groups |
|
|
186
|
+
| `hasRole(user, role)` | Check if user has a specific group |
|
|
187
|
+
| `getPermissions(user)` | Get resolved permissions from groups |
|
|
188
|
+
| `hasPermission(user, permission)` | Check if user has a permission |
|
|
189
|
+
| `hasAllPermissions(user, permissions)` | Check if user has all permissions |
|
|
190
|
+
| `hasAnyPermission(user, permissions)` | Check if user has any permission |
|
|
191
|
+
|
|
192
|
+
### MastraAuthOkta
|
|
193
|
+
|
|
194
|
+
| Method | Description |
|
|
195
|
+
| ----------------------------------- | --------------------------- |
|
|
196
|
+
| `authenticateToken(token, request)` | Verify JWT and return user |
|
|
197
|
+
| `authorizeUser(user, request)` | Check if user is authorized |
|
|
198
|
+
|
|
199
|
+
## Requirements
|
|
200
|
+
|
|
201
|
+
- Node.js 22.13.0 or later
|
|
202
|
+
- Okta account with:
|
|
203
|
+
- OAuth application (for authentication)
|
|
204
|
+
- API token (for RBAC group fetching)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MastraAuthOkta - Okta authentication provider for Mastra with SSO support.
|
|
3
|
+
*
|
|
4
|
+
* Supports OAuth 2.0 / OIDC login flow with client_secret and session management.
|
|
5
|
+
*/
|
|
6
|
+
import type { ISSOProvider, ISessionProvider, IUserProvider, Session, SSOCallbackResult, SSOLoginConfig } from '@mastra/core/auth';
|
|
7
|
+
import { MastraAuthProvider } from '@mastra/core/server';
|
|
8
|
+
import type { HonoRequest } from 'hono';
|
|
9
|
+
import type { OktaUser, MastraAuthOktaOptions } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Mastra authentication provider for Okta with SSO support.
|
|
12
|
+
*
|
|
13
|
+
* Implements OAuth 2.0 / OIDC login flow with encrypted session cookies.
|
|
14
|
+
*
|
|
15
|
+
* @example Basic usage with SSO
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { MastraAuthOkta } from '@mastra/auth-okta';
|
|
18
|
+
*
|
|
19
|
+
* const auth = new MastraAuthOkta({
|
|
20
|
+
* domain: 'dev-123456.okta.com',
|
|
21
|
+
* clientId: 'your-client-id',
|
|
22
|
+
* clientSecret: 'your-client-secret',
|
|
23
|
+
* redirectUri: 'http://localhost:4111/api/auth/callback',
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class MastraAuthOkta extends MastraAuthProvider<OktaUser> implements ISSOProvider<OktaUser>, ISessionProvider<Session>, IUserProvider<OktaUser> {
|
|
28
|
+
protected domain: string;
|
|
29
|
+
protected clientId: string;
|
|
30
|
+
protected clientSecret: string;
|
|
31
|
+
protected issuer: string;
|
|
32
|
+
protected redirectUri: string;
|
|
33
|
+
protected scopes: string[];
|
|
34
|
+
protected cookieName: string;
|
|
35
|
+
protected cookieMaxAge: number;
|
|
36
|
+
protected cookiePassword: string;
|
|
37
|
+
protected secureCookies: boolean;
|
|
38
|
+
protected apiToken?: string;
|
|
39
|
+
private jwks;
|
|
40
|
+
constructor(options?: MastraAuthOktaOptions);
|
|
41
|
+
/**
|
|
42
|
+
* Authenticate a token from the request.
|
|
43
|
+
* First tries to read from session cookie, then falls back to Authorization header.
|
|
44
|
+
*/
|
|
45
|
+
authenticateToken(token: string, request: HonoRequest | Request): Promise<OktaUser | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Authorize a user.
|
|
48
|
+
*/
|
|
49
|
+
authorizeUser(user: OktaUser, _request: HonoRequest): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current user from the request session.
|
|
52
|
+
*/
|
|
53
|
+
getCurrentUser(request: Request): Promise<OktaUser | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Get a user by ID via the Okta Users API.
|
|
56
|
+
* Requires an API token (set OKTA_API_TOKEN or pass apiToken in options).
|
|
57
|
+
* Returns null if no API token is configured or user is not found.
|
|
58
|
+
*/
|
|
59
|
+
getUser(userId: string): Promise<OktaUser | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Get user from session cookie.
|
|
62
|
+
*/
|
|
63
|
+
private getUserFromSession;
|
|
64
|
+
/**
|
|
65
|
+
* Extract the raw ID token from the encrypted session cookie.
|
|
66
|
+
* Used to provide id_token_hint for Okta logout.
|
|
67
|
+
*/
|
|
68
|
+
private getIdTokenFromSession;
|
|
69
|
+
/**
|
|
70
|
+
* Get the URL to redirect users to for Okta login.
|
|
71
|
+
* Uses client_secret authentication (no PKCE) since this is a confidential client.
|
|
72
|
+
*/
|
|
73
|
+
getLoginUrl(redirectUri: string, state: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Handle the OAuth callback from Okta.
|
|
76
|
+
* Note: The server passes only the stateId (UUID part), not the full state.
|
|
77
|
+
*/
|
|
78
|
+
handleCallback(code: string, stateId: string): Promise<SSOCallbackResult<OktaUser>>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the URL to redirect users to for logout.
|
|
81
|
+
* Includes id_token_hint from session when available (required by Okta).
|
|
82
|
+
*/
|
|
83
|
+
getLogoutUrl(redirectUri: string, request?: Request): Promise<string | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Get cookies to set during login.
|
|
86
|
+
*/
|
|
87
|
+
getLoginCookies(_state: string): string[];
|
|
88
|
+
/**
|
|
89
|
+
* Get the configuration for rendering the login button.
|
|
90
|
+
*/
|
|
91
|
+
getLoginButtonConfig(): SSOLoginConfig;
|
|
92
|
+
createSession(userId: string, metadata?: Record<string, unknown>): Promise<Session>;
|
|
93
|
+
validateSession(_sessionId: string): Promise<Session | null>;
|
|
94
|
+
destroySession(_sessionId: string): Promise<void>;
|
|
95
|
+
refreshSession(_sessionId: string): Promise<Session | null>;
|
|
96
|
+
getSessionIdFromRequest(_request: Request): string | null;
|
|
97
|
+
getSessionHeaders(_session: Session): Record<string, string>;
|
|
98
|
+
getClearSessionHeaders(): Record<string, string>;
|
|
99
|
+
/**
|
|
100
|
+
* Build consistent cookie attribute string for set/clear operations.
|
|
101
|
+
*/
|
|
102
|
+
private cookieFlags;
|
|
103
|
+
/**
|
|
104
|
+
* Get the Okta domain.
|
|
105
|
+
*/
|
|
106
|
+
getDomain(): string;
|
|
107
|
+
/**
|
|
108
|
+
* Get the configured client ID.
|
|
109
|
+
*/
|
|
110
|
+
getClientId(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Get the configured redirect URI.
|
|
113
|
+
*/
|
|
114
|
+
getRedirectUri(): string;
|
|
115
|
+
/**
|
|
116
|
+
* Get the issuer URL.
|
|
117
|
+
*/
|
|
118
|
+
getIssuer(): string;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=auth-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA0ElE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cACX,SAAQ,kBAAkB,CAAC,QAAQ,CACnC,YAAW,YAAY,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC;IAErF,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,QAAQ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