@mastra/auth-okta 0.2.0 → 0.2.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.
- package/CHANGELOG.md +16 -0
- package/dist/_types/@internal_auth/dist/ee/interfaces/fga.d.ts +11 -0
- package/dist/_types/@internal_auth/dist/types/index.d.ts +6 -2
- package/dist/auth-provider.d.ts +1 -8
- package/dist/auth-provider.d.ts.map +1 -1
- package/dist/index.cjs +21 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mastra/auth-okta
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed reading request headers from Express-style plain header objects so cookie-based auth providers no longer throw and fail with a misleading 401. ([#21261](https://github.com/mastra-ai/mastra/pull/21261))
|
|
8
|
+
|
|
9
|
+
Related to https://github.com/mastra-ai/mastra/issues/21253
|
|
10
|
+
|
|
11
|
+
## 0.2.1-alpha.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Fixed reading request headers from Express-style plain header objects so cookie-based auth providers no longer throw and fail with a misleading 401. ([#21261](https://github.com/mastra-ai/mastra/pull/21261))
|
|
16
|
+
|
|
17
|
+
Related to https://github.com/mastra-ai/mastra/issues/21253
|
|
18
|
+
|
|
3
19
|
## 0.2.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -35,6 +35,17 @@ export type ActorSignal = true | {
|
|
|
35
35
|
permissions?: MastraFGAPermissionInput[];
|
|
36
36
|
/** Additional provider-specific scope for the actor (e.g. tenant, environment). */
|
|
37
37
|
scope?: Record<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* Opt in to propagating this actor into the agent/tool calls the framework
|
|
40
|
+
* makes for declarative workflow steps (`.then(agent)` / `.then(tool)`)
|
|
41
|
+
* within this run's own execution tree.
|
|
42
|
+
*
|
|
43
|
+
* Never implicit, and ignored by authorization itself. Custom step
|
|
44
|
+
* `execute` closures are not covered — they already receive `actor` on the
|
|
45
|
+
* step context and must pass it explicitly. The `true` shorthand cannot
|
|
46
|
+
* opt in; use this object form.
|
|
47
|
+
*/
|
|
48
|
+
propagate?: boolean;
|
|
38
49
|
};
|
|
39
50
|
/**
|
|
40
51
|
* Optional context for an authorization check.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface HonoRequestLike {
|
|
2
2
|
raw?: Request;
|
|
3
|
-
headers?: Headers
|
|
4
|
-
header(name: string): string | undefined;
|
|
3
|
+
headers?: Headers | Record<string, string | string[] | undefined>;
|
|
4
|
+
header?(name: string): string | undefined;
|
|
5
5
|
}
|
|
6
6
|
export type MastraAuthRequest = Request | HonoRequestLike;
|
|
7
7
|
export type AuthenticateTokenFn<TUser, TResult = Promise<TUser | null>> = {
|
|
@@ -10,6 +10,10 @@ export type AuthenticateTokenFn<TUser, TResult = Promise<TUser | null>> = {
|
|
|
10
10
|
export type AuthorizeUserFn<TUser, TResult = Promise<boolean> | boolean> = {
|
|
11
11
|
bivarianceHack(user: TUser, request: MastraAuthRequest): TResult;
|
|
12
12
|
}['bivarianceHack'];
|
|
13
|
+
/**
|
|
14
|
+
* Read a request header across fetch, Hono, and Express-style request shapes.
|
|
15
|
+
* Must not throw when `headers` is a plain object (Express `IncomingHttpHeaders`).
|
|
16
|
+
*/
|
|
13
17
|
export declare function getRequestHeader(request: MastraAuthRequest, name: string): string | null;
|
|
14
18
|
export declare function getWebRequest(request: MastraAuthRequest): Request | undefined;
|
|
15
19
|
export type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'ALL';
|
package/dist/auth-provider.d.ts
CHANGED
|
@@ -3,14 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Supports OAuth 2.0 / OIDC login flow with client_secret and session management.
|
|
5
5
|
*/
|
|
6
|
-
import type { ISSOProvider, ISessionProvider, IUserProvider, Session, SSOCallbackResult, SSOLoginConfig } from './_types/@internal_auth/dist/index.d.ts';
|
|
6
|
+
import type { ISSOProvider, ISessionProvider, IUserProvider, MastraAuthRequest, Session, SSOCallbackResult, SSOLoginConfig } from './_types/@internal_auth/dist/index.d.ts';
|
|
7
7
|
import { MastraAuthProvider } from './_types/@internal_auth/dist/provider/index.d.ts';
|
|
8
|
-
type HonoRequestLike = {
|
|
9
|
-
raw?: Request;
|
|
10
|
-
headers?: Headers;
|
|
11
|
-
header(name: string): string | undefined;
|
|
12
|
-
};
|
|
13
|
-
type MastraAuthRequest = Request | HonoRequestLike;
|
|
14
8
|
import type { OktaUser, MastraAuthOktaOptions } from './types.js';
|
|
15
9
|
/**
|
|
16
10
|
* Mastra authentication provider for Okta with SSO support.
|
|
@@ -124,5 +118,4 @@ export declare class MastraAuthOkta extends MastraAuthProvider<OktaUser> impleme
|
|
|
124
118
|
*/
|
|
125
119
|
getIssuer(): string;
|
|
126
120
|
}
|
|
127
|
-
export {};
|
|
128
121
|
//# sourceMappingURL=auth-provider.d.ts.map
|
|
@@ -1 +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,gBAAgB,CAAC;
|
|
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,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBA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B;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
|
package/dist/index.cjs
CHANGED
|
@@ -315,6 +315,27 @@ var MastraRBACOkta = class {
|
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
//#endregion
|
|
318
|
+
//#region ../../packages/_internals/auth/dist/types/index.js
|
|
319
|
+
function headerFromPlainObject(headers, name) {
|
|
320
|
+
const normalizedName = name.toLowerCase();
|
|
321
|
+
const matchingKey = Object.keys(headers).find((key) => key.toLowerCase() === normalizedName);
|
|
322
|
+
const value = matchingKey === void 0 ? void 0 : headers[matchingKey];
|
|
323
|
+
return Array.isArray(value) ? value[0] ?? null : value ?? null;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Read a request header across fetch, Hono, and Express-style request shapes.
|
|
327
|
+
* Must not throw when `headers` is a plain object (Express `IncomingHttpHeaders`).
|
|
328
|
+
*/
|
|
329
|
+
function getRequestHeader(request, name) {
|
|
330
|
+
if (request instanceof Request) return request.headers.get(name);
|
|
331
|
+
if (request.raw instanceof Request) return request.raw.headers.get(name);
|
|
332
|
+
const headers = request.headers;
|
|
333
|
+
if (headers instanceof Headers) return headers.get(name);
|
|
334
|
+
if (typeof request.header === "function") return request.header(name) ?? null;
|
|
335
|
+
if (headers && typeof headers === "object") return headerFromPlainObject(headers, name);
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
318
339
|
//#region ../../packages/_internal-core/dist/logger/index.js
|
|
319
340
|
const RegisteredLogger = {
|
|
320
341
|
AGENT: "AGENT",
|
|
@@ -555,10 +576,6 @@ function trimTrailingSlashes(value) {
|
|
|
555
576
|
while (end > 0 && value[end - 1] === "/") end--;
|
|
556
577
|
return value.slice(0, end);
|
|
557
578
|
}
|
|
558
|
-
function getRequestHeader(request, name) {
|
|
559
|
-
if (request instanceof Request) return request.headers.get(name);
|
|
560
|
-
return request.raw?.headers.get(name) ?? request.headers?.get(name) ?? request.header(name) ?? null;
|
|
561
|
-
}
|
|
562
579
|
/** Default cookie name for Okta sessions */
|
|
563
580
|
const DEFAULT_COOKIE_NAME = "okta_session";
|
|
564
581
|
/** Default cookie max age (24 hours) */
|