@sixb/server 0.1.12 → 0.1.13
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/README.md +5 -4
- package/dist/auth/access-token-boundary.d.ts +13 -9
- package/dist/auth/access-token-boundary.d.ts.map +1 -1
- package/dist/auth/client-address.d.ts +12 -0
- package/dist/auth/client-address.d.ts.map +1 -0
- package/dist/auth/guard.d.ts.map +1 -1
- package/dist/auth/public-routes.d.ts +5 -0
- package/dist/auth/public-routes.d.ts.map +1 -1
- package/dist/auth/rate-limit.d.ts +15 -0
- package/dist/auth/rate-limit.d.ts.map +1 -0
- package/dist/auth/scope.d.ts +8 -3
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/auth/shared-access.d.ts.map +1 -1
- package/dist/index.js +578 -455
- package/dist/index.js.map +40 -38
- package/dist/openapi/security.d.ts +34 -10
- package/dist/openapi/security.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +64 -17
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/connectors.d.ts.map +1 -1
- package/dist/routes/events.d.ts +0 -4
- package/dist/routes/events.d.ts.map +1 -1
- package/dist/routes/files.d.ts +15 -2
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/models.d.ts +7 -7
- package/dist/routes/ontology.d.ts +13 -1
- package/dist/routes/ontology.d.ts.map +1 -1
- package/dist/routes/shared-access.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +30 -30
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/agents.d.ts +2 -3
- package/dist/routes/ws/agents.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +241 -85
- package/dist/schemas/auth.d.ts.map +1 -1
- package/dist/schemas/common.d.ts +11 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/events.d.ts +74 -44
- package/dist/schemas/events.d.ts.map +1 -1
- package/dist/schemas/models.d.ts +38 -38
- package/dist/schemas/ontology.d.ts +160 -0
- package/dist/schemas/ontology.d.ts.map +1 -1
- package/dist/schemas/workflows.d.ts +180 -190
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/utils/ws.d.ts +1 -2
- package/dist/utils/ws.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/auth/access-token-boundary.ts +31 -30
- package/src/auth/client-address.ts +67 -0
- package/src/auth/guard.ts +13 -4
- package/src/auth/public-routes.ts +9 -2
- package/src/auth/rate-limit.ts +43 -0
- package/src/auth/scope.ts +13 -3
- package/src/auth/shared-access.ts +0 -3
- package/src/openapi/security.ts +37 -17
- package/src/routes/action-runs.ts +5 -5
- package/src/routes/actions.ts +4 -4
- package/src/routes/agents.ts +9 -9
- package/src/routes/ai-accounting.ts +10 -10
- package/src/routes/auth.ts +331 -432
- package/src/routes/connector-connection-runs.ts +5 -5
- package/src/routes/connector-connections.ts +3 -3
- package/src/routes/connectors.ts +2 -2
- package/src/routes/events.ts +2 -2
- package/src/routes/files.ts +30 -15
- package/src/routes/links.ts +3 -3
- package/src/routes/logs.ts +2 -2
- package/src/routes/objects.ts +12 -12
- package/src/routes/ontology.ts +27 -9
- package/src/routes/pipelines.ts +2 -2
- package/src/routes/project.ts +2 -2
- package/src/routes/share-grants.ts +4 -4
- package/src/routes/shared-access.ts +3 -2
- package/src/routes/syncs.ts +2 -2
- package/src/routes/telemetry.ts +5 -5
- package/src/routes/workflows.ts +18 -19
- package/src/routes/ws/agents.ts +4 -5
- package/src/schemas/auth.ts +27 -8
- package/src/schemas/common.ts +6 -0
- package/src/schemas/events.ts +35 -7
- package/src/schemas/ontology.ts +16 -1
- package/src/schemas/workflows.ts +4 -9
- package/src/server.ts +35 -5
- package/src/utils/ws.ts +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/schemas/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEnD,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;EAK3C,CAAA"}
|
package/dist/server.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export interface SixbServerOptions {
|
|
|
13
13
|
authExperience?: SixbAuthExperienceOptions;
|
|
14
14
|
/** Optional server limits for short-lived shared-access sessions. */
|
|
15
15
|
sharedAccess?: SixbSharedAccessOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Proxies whose `x-forwarded-for` entries identify the client: IP addresses, CIDR ranges, or
|
|
18
|
+
* `"private"` for loopback, private, and link-local networks. Defaults to `["private"]`.
|
|
19
|
+
*/
|
|
20
|
+
trustedProxies?: readonly string[];
|
|
16
21
|
}
|
|
17
22
|
export declare function createSixbServer(options: SixbServerOptions): SixbServer;
|
|
18
23
|
export declare class SixbServer {
|
|
@@ -25,6 +30,7 @@ export declare class SixbServer {
|
|
|
25
30
|
private readonly authRedirectContextResolver;
|
|
26
31
|
private readonly authExperience?;
|
|
27
32
|
private readonly sharedAccessOptions;
|
|
33
|
+
private readonly resolveClientAddress;
|
|
28
34
|
private app;
|
|
29
35
|
private bunServer;
|
|
30
36
|
private maintenance;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,YAAY,EAAE,MAAM,YAAY,CAAA;AAIzE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,6BAA6B,EAClC,KAAK,2BAA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;IAC7D,OAAO,CAAC,WAAW,CAAyC;gBAEhD,OAAO,EAAE,iBAAiB;IAiBtC,OAAO,IAAI,YAAY;IAIvB,OAAO,IAAI,MAAM;IAIjB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB;IAIxD,0BAA0B,CACxB,OAAO,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAClD,KAAK,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,GAC/C,UAAU,CAAC,0BAA0B,CAAC;IAIzC,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAIlD,+BAA+B,CAAC,QAAQ,EAAE,OAAO,GAAG,gCAAgC;IAIpF,gCAAgC,CAC9B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,2BAA2B,GACjC,6BAA6B;IAIhC,mBAAmB,IAAI,4BAA4B;IAInD,iBAAiB,IAAI,yBAAyB,GAAG,SAAS;IAI1D,sBAAsB,IAAI,uBAAuB;IAI3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+BtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAe5B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiP/C;AAiED,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
package/dist/utils/ws.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { OntologySource } from "@sixb/core";
|
|
2
1
|
import type { Sixb } from "@sixb/core/internal/request-execution";
|
|
3
2
|
export declare function safeSend(target: {
|
|
4
3
|
send: (message: string) => void;
|
|
@@ -6,6 +5,6 @@ export declare function safeSend(target: {
|
|
|
6
5
|
/** Stable per-connection key for a subscription-state WeakMap (the raw socket when Elysia wraps it). */
|
|
7
6
|
export declare function wsStateKey(ws: object): object;
|
|
8
7
|
/** The execution SDK attached once when the WebSocket request crosses the auth boundary. */
|
|
9
|
-
export declare function wsRequestSixb(ws: object): Sixb
|
|
8
|
+
export declare function wsRequestSixb(ws: object): Sixb | null;
|
|
10
9
|
export declare function decodeWsMessage(message: unknown): Promise<unknown>;
|
|
11
10
|
//# sourceMappingURL=ws.d.ts.map
|
package/dist/utils/ws.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/utils/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/utils/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAA;AAEjE,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAM5F;AAED,wGAAwG;AACxG,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAOrD;AAUD,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CA4BxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "HTTP and WebSocket API server for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"zod-to-json-schema": "^3.24.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@sixb/core": "0.1.
|
|
41
|
+
"@sixb/core": "0.1.13"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@sixb/auth-magic-link": "0.1.4",
|
|
45
45
|
"@sixb/auth-oidc": "0.1.3",
|
|
46
|
-
"@sixb/core": "0.1.
|
|
47
|
-
"@sixb/sqlite": "0.1.
|
|
46
|
+
"@sixb/core": "0.1.13",
|
|
47
|
+
"@sixb/sqlite": "0.1.13",
|
|
48
48
|
"@types/bun": "latest",
|
|
49
49
|
"typescript": "^5.7.0"
|
|
50
50
|
},
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { isCsrfExemptMethod } from "@sixb/core/internal/auth"
|
|
1
|
+
import { type AuthenticatedRequestAuthSession, isCsrfExemptMethod } from "@sixb/core/internal/auth"
|
|
2
2
|
import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http"
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
SIXB_ACCESS_TOKEN_MUTATION_SECURITY_REQUIREMENT,
|
|
5
|
+
SIXB_ACCESS_TOKEN_READ_SECURITY_REQUIREMENT,
|
|
6
6
|
SIXB_SHARED_MUTATION_SECURITY_REQUIREMENT,
|
|
7
7
|
SIXB_SHARED_READ_SECURITY_REQUIREMENT,
|
|
8
8
|
} from "../openapi/security"
|
|
9
9
|
import type { RouteAccess } from "./public-routes"
|
|
10
10
|
|
|
11
|
-
export type AuthCredentialSource = "session" | "accessToken"
|
|
12
|
-
|
|
13
11
|
export interface AccessTokenRoute {
|
|
14
12
|
readonly operationId: string
|
|
15
13
|
readonly method: string
|
|
@@ -17,16 +15,16 @@ export interface AccessTokenRoute {
|
|
|
17
15
|
readonly sharedSession: boolean
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
// The routes that accept
|
|
21
|
-
// SIXB_API_ROUTES table in @sixb/core. `isAccessTokenRoute` enforces this list at
|
|
22
|
-
// `
|
|
23
|
-
// boundary and the documented contract cannot drift apart. The agent
|
|
24
|
-
// `agentApi` projection of the same table, which the table's load-time
|
|
25
|
-
// subset of this one.
|
|
18
|
+
// The routes that accept personal and service-account access tokens: the `accessToken` projection
|
|
19
|
+
// of the canonical SIXB_API_ROUTES table in @sixb/core. `isAccessTokenRoute` enforces this list at
|
|
20
|
+
// request time and `accessTokenSecurityRequirement` derives each route's OpenAPI security entry
|
|
21
|
+
// from it, so the enforced boundary and the documented contract cannot drift apart. The agent
|
|
22
|
+
// gateway allow-list is the `agentApi` projection of the same table, which the table's load-time
|
|
23
|
+
// invariant keeps a strict subset of this one.
|
|
26
24
|
//
|
|
27
|
-
//
|
|
28
|
-
// webhook, and WebSocket routes stay session-only because
|
|
29
|
-
// from SIXB_API_ROUTES.
|
|
25
|
+
// Access tokens should only reach routes that enforce execution-bound authority. Admin, browser,
|
|
26
|
+
// webhook, and WebSocket routes stay session-only because access-token use is intentionally absent
|
|
27
|
+
// from SIXB_API_ROUTES. A native client's session, though also a bearer token, is a session.
|
|
30
28
|
export const ACCESS_TOKEN_ROUTES: readonly AccessTokenRoute[] = SIXB_API_ROUTES.filter(
|
|
31
29
|
(route) => route.accessToken
|
|
32
30
|
).map((route) => ({
|
|
@@ -37,23 +35,22 @@ export const ACCESS_TOKEN_ROUTES: readonly AccessTokenRoute[] = SIXB_API_ROUTES.
|
|
|
37
35
|
}))
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
|
-
* OpenAPI security requirement for a
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* never claim bearer access without being added to the boundary.
|
|
38
|
+
* OpenAPI security requirement for a route that accepts access tokens, derived from the canonical
|
|
39
|
+
* table: an access token or a session, plus the CSRF token for a browser session's mutations.
|
|
40
|
+
* Throws when the operation is not a registered access-token route, so a route can never claim
|
|
41
|
+
* access-token use without being added to the boundary.
|
|
45
42
|
*/
|
|
46
|
-
export function
|
|
43
|
+
export function accessTokenSecurityRequirement(operationId: string) {
|
|
47
44
|
const route = ACCESS_TOKEN_ROUTES.find((candidate) => candidate.operationId === operationId)
|
|
48
45
|
if (!route) {
|
|
49
46
|
throw new Error(
|
|
50
|
-
`[SixbServer] '${operationId}' is not a registered
|
|
47
|
+
`[SixbServer] '${operationId}' is not a registered access-token route. Add it to ACCESS_TOKEN_ROUTES.`
|
|
51
48
|
)
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
const standard = isCsrfExemptMethod(route.method)
|
|
55
|
-
?
|
|
56
|
-
:
|
|
52
|
+
? SIXB_ACCESS_TOKEN_READ_SECURITY_REQUIREMENT
|
|
53
|
+
: SIXB_ACCESS_TOKEN_MUTATION_SECURITY_REQUIREMENT
|
|
57
54
|
if (!route.sharedSession) return standard
|
|
58
55
|
return [
|
|
59
56
|
...standard,
|
|
@@ -73,11 +70,15 @@ export function isAccessTokenRoute(request: Request): boolean {
|
|
|
73
70
|
)
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
):
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
/** How a request carried its credential: an ambient browser cookie, or an explicit bearer token. */
|
|
74
|
+
export type CredentialTransport = "cookie" | "bearer"
|
|
75
|
+
|
|
76
|
+
export function credentialTransport(caller: AuthenticatedRequestAuthSession): CredentialTransport {
|
|
77
|
+
return caller.credentialSource === "session" && !caller.session.bearer ? "cookie" : "bearer"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function shouldVerifyCsrf(route: RouteAccess, transport: CredentialTransport): boolean {
|
|
81
|
+
// CSRF protects ambient browser cookies. A bearer token (a native client's session or an access
|
|
82
|
+
// token) is an explicit request credential, so it skips CSRF.
|
|
83
|
+
return route.csrfProtected && transport === "cookie"
|
|
83
84
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { BlockList, isIP, isIPv4 } from "node:net"
|
|
2
|
+
|
|
3
|
+
/** Loopback, private, and link-local networks: where a reverse proxy in front of Sixb connects from. */
|
|
4
|
+
export const PRIVATE_NETWORKS = "private"
|
|
5
|
+
|
|
6
|
+
const PRIVATE_NETWORK_RANGES = [
|
|
7
|
+
"127.0.0.0/8",
|
|
8
|
+
"10.0.0.0/8",
|
|
9
|
+
"172.16.0.0/12",
|
|
10
|
+
"192.168.0.0/16",
|
|
11
|
+
"169.254.0.0/16",
|
|
12
|
+
"::1/128",
|
|
13
|
+
"fc00::/7",
|
|
14
|
+
"fe80::/10",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
export type ClientAddressResolver = (socketAddress: string, forwardedFor: string | null) => string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the client a request came from.
|
|
21
|
+
*
|
|
22
|
+
* Starts at the socket peer and walks `x-forwarded-for` right to left while the current hop is a
|
|
23
|
+
* trusted proxy. Each proxy appends the address it accepted the connection from, so everything left
|
|
24
|
+
* of the first untrusted hop was written by the client and is never read.
|
|
25
|
+
*/
|
|
26
|
+
export function createClientAddressResolver(
|
|
27
|
+
trustedProxies: readonly string[]
|
|
28
|
+
): ClientAddressResolver {
|
|
29
|
+
const trusted = new BlockList()
|
|
30
|
+
for (const entry of trustedProxies.flatMap((value) =>
|
|
31
|
+
value === PRIVATE_NETWORKS ? PRIVATE_NETWORK_RANGES : [value]
|
|
32
|
+
)) {
|
|
33
|
+
addTrustedRange(trusted, entry)
|
|
34
|
+
}
|
|
35
|
+
const isTrusted = (address: string) => trusted.check(address, isIPv4(address) ? "ipv4" : "ipv6")
|
|
36
|
+
|
|
37
|
+
return (socketAddress, forwardedFor) => {
|
|
38
|
+
let address = normalizeAddress(socketAddress)
|
|
39
|
+
const hops = forwardedFor?.split(",") ?? []
|
|
40
|
+
for (let index = hops.length - 1; index >= 0 && isTrusted(address); index -= 1) {
|
|
41
|
+
const hop = normalizeAddress(hops[index]?.trim() ?? "")
|
|
42
|
+
if (!isIP(hop)) break
|
|
43
|
+
address = hop
|
|
44
|
+
}
|
|
45
|
+
return address
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function addTrustedRange(list: BlockList, entry: string): void {
|
|
50
|
+
const [address = "", prefix, ...rest] = entry.split("/")
|
|
51
|
+
const family = isIP(address)
|
|
52
|
+
const maxBits = family === 4 ? 32 : 128
|
|
53
|
+
const bits = prefix === undefined ? maxBits : Number(prefix)
|
|
54
|
+
const validPrefix = prefix === undefined || /^\d{1,3}$/.test(prefix)
|
|
55
|
+
if (!family || !validPrefix || rest.length > 0 || bits > maxBits) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`[SixbServer] Trusted proxy '${entry}' is not an IP address, CIDR range, or '${PRIVATE_NETWORKS}'.`
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
list.addSubnet(address, bits, family === 4 ? "ipv4" : "ipv6")
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Dual-stack listeners report IPv4 peers as `::ffff:a.b.c.d`.
|
|
64
|
+
function normalizeAddress(address: string): string {
|
|
65
|
+
const lower = address.toLowerCase()
|
|
66
|
+
return lower.startsWith("::ffff:") && isIPv4(lower.slice(7)) ? lower.slice(7) : lower
|
|
67
|
+
}
|
package/src/auth/guard.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
type AuthenticatedRequestAuthSession,
|
|
4
4
|
verifyDoubleSubmitCsrf,
|
|
5
5
|
} from "@sixb/core/internal/auth"
|
|
6
|
-
import { isAccessTokenRoute,
|
|
6
|
+
import { credentialTransport, isAccessTokenRoute, shouldVerifyCsrf } from "./access-token-boundary"
|
|
7
7
|
import { sessionCanAccessApplication } from "./application-access"
|
|
8
8
|
import { BrowserOriginError, type ResolveRequestAuthContext } from "./browser-origin"
|
|
9
9
|
import { classifyRoute } from "./public-routes"
|
|
@@ -86,7 +86,14 @@ export class ServerAuthGuard {
|
|
|
86
86
|
return { kind: "deny", response: jsonAuthRequiredResponse() }
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
// Application access gates the web app a browser session belongs to. A native client's session
|
|
90
|
+
// and an access token belong to no web app: grants alone decide what they may do. Account pages
|
|
91
|
+
// serve every signed-in user.
|
|
92
|
+
const deniedApplication = (caller: AuthenticatedRequestAuthSession) =>
|
|
93
|
+
!route.account &&
|
|
94
|
+
credentialTransport(caller) === "cookie" &&
|
|
95
|
+
!sessionCanAccessApplication(this.host, caller, authContext.audience)
|
|
96
|
+
if (deniedApplication(session)) {
|
|
90
97
|
return {
|
|
91
98
|
kind: "deny",
|
|
92
99
|
response: jsonForbiddenResponse("Application access is not allowed"),
|
|
@@ -101,14 +108,16 @@ export class ServerAuthGuard {
|
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
if (
|
|
104
|
-
|
|
111
|
+
shouldVerifyCsrf(route, credentialTransport(session)) &&
|
|
105
112
|
!this.verifyCsrf(request, session)
|
|
106
113
|
) {
|
|
107
114
|
return { kind: "deny", response: jsonCsrfFailedResponse() }
|
|
108
115
|
}
|
|
109
116
|
|
|
117
|
+
// Browser sessions renew on foreground use; native sessions renew by refreshing their tokens.
|
|
110
118
|
if (
|
|
111
119
|
session.credentialSource === "session" &&
|
|
120
|
+
credentialTransport(session) === "cookie" &&
|
|
112
121
|
route.kind !== "websocket" &&
|
|
113
122
|
!isSessionTerminationRequest(request) &&
|
|
114
123
|
hasForegroundSessionActivity(request)
|
|
@@ -130,7 +139,7 @@ export class ServerAuthGuard {
|
|
|
130
139
|
}
|
|
131
140
|
return { kind: "deny", response: jsonAuthRequiredResponse() }
|
|
132
141
|
}
|
|
133
|
-
if (
|
|
142
|
+
if (deniedApplication(activeSession)) {
|
|
134
143
|
return {
|
|
135
144
|
kind: "deny",
|
|
136
145
|
response: jsonForbiddenResponse("Application access is not allowed"),
|
|
@@ -9,6 +9,11 @@ export type RouteAccessKind = "public" | "api" | "html" | "websocket"
|
|
|
9
9
|
export interface RouteAccess {
|
|
10
10
|
readonly kind: RouteAccessKind
|
|
11
11
|
readonly csrfProtected: boolean
|
|
12
|
+
/**
|
|
13
|
+
* An instance account page every signed-in user needs, whichever web app they may open: approving
|
|
14
|
+
* a CLI login. Application access does not gate it.
|
|
15
|
+
*/
|
|
16
|
+
readonly account?: true
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
export function classifyRoute(request: Request): RouteAccess {
|
|
@@ -28,7 +33,7 @@ export function classifyRoute(request: Request): RouteAccess {
|
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
if (pathname === "/auth/device") {
|
|
31
|
-
return { kind: "html", csrfProtected: !isCsrfExemptMethod(request.method) }
|
|
36
|
+
return { kind: "html", csrfProtected: !isCsrfExemptMethod(request.method), account: true }
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
if (pathname === "/docs" || pathname.startsWith("/docs/")) {
|
|
@@ -81,9 +86,11 @@ export function isPublicRoute(pathname: string, method: string): boolean {
|
|
|
81
86
|
return true
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
// The refresh token in the body is the credential; the access token it replaces has expired.
|
|
84
90
|
if (
|
|
85
91
|
(pathname === "/api/auth/device-authorizations" ||
|
|
86
|
-
pathname === "/api/auth/device-authorizations/token"
|
|
92
|
+
pathname === "/api/auth/device-authorizations/token" ||
|
|
93
|
+
pathname === "/api/auth/refresh") &&
|
|
87
94
|
normalizedMethod === "POST"
|
|
88
95
|
) {
|
|
89
96
|
return true
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isIPv4 } from "node:net"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fixed-window request limit per client address, held in process memory.
|
|
5
|
+
*
|
|
6
|
+
* IPv6 addresses share one window per /64, the block a single host is usually assigned.
|
|
7
|
+
* Windows all have the same length, so insertion order is expiry order and pruning stops at the
|
|
8
|
+
* first live window.
|
|
9
|
+
*/
|
|
10
|
+
export class ClientAddressRateLimiter {
|
|
11
|
+
private readonly windows = new Map<string, { count: number; readonly resetAt: number }>()
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
private readonly limit: number,
|
|
15
|
+
private readonly windowMs: number
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
tryConsume(address: string | undefined, nowMs = Date.now()): boolean {
|
|
19
|
+
for (const [key, window] of this.windows) {
|
|
20
|
+
if (window.resetAt > nowMs) break
|
|
21
|
+
this.windows.delete(key)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const key = rateLimitKey(address)
|
|
25
|
+
const window = this.windows.get(key)
|
|
26
|
+
if (!window) {
|
|
27
|
+
this.windows.set(key, { count: 1, resetAt: nowMs + this.windowMs })
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
if (window.count >= this.limit) return false
|
|
31
|
+
window.count += 1
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function rateLimitKey(address: string | undefined): string {
|
|
37
|
+
if (!address || isIPv4(address)) return address ?? ""
|
|
38
|
+
const [head = "", tail = ""] = address.split("::")
|
|
39
|
+
const left = head ? head.split(":") : []
|
|
40
|
+
const right = tail ? tail.split(":") : []
|
|
41
|
+
const zeros = Array<string>(Math.max(0, 8 - left.length - right.length)).fill("0")
|
|
42
|
+
return `${[...left, ...zeros, ...right].slice(0, 4).join(":")}::/64`
|
|
43
|
+
}
|
package/src/auth/scope.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthenticatedRequestAuthSession } from "@sixb/core/internal/auth"
|
|
2
2
|
import type { RequestExecutionAuthorization, Sixb } from "@sixb/core/internal/request-execution"
|
|
3
3
|
import type { AgentRunRecord, ConversationAgentRunRecord } from "@sixb/core/storage"
|
|
4
|
+
import type { ServerAuthGuardDecision } from "./guard"
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Per-request authorization state attached by the server's auth derive.
|
|
@@ -9,7 +10,7 @@ import type { AgentRunRecord, ConversationAgentRunRecord } from "@sixb/core/stor
|
|
|
9
10
|
* requests, and absent only for public routes that do not execute protected domain operations.
|
|
10
11
|
*/
|
|
11
12
|
export interface RequestAuthState {
|
|
12
|
-
readonly sixb: Sixb
|
|
13
|
+
readonly sixb: Sixb | null
|
|
13
14
|
/** Present for requests proxied through the run-scoped agent API gateway. */
|
|
14
15
|
readonly agentRun?: ConversationAgentRunRecord
|
|
15
16
|
/** Identifies which kind of active agent execution owns a gateway request. */
|
|
@@ -60,10 +61,19 @@ export function requestAuthState(context: unknown): RequestAuthState {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
export function requireRequestSixb(context: unknown): Sixb
|
|
64
|
+
export function requireRequestSixb(context: unknown): Sixb {
|
|
64
65
|
const sixb = requestAuthState(context).sixb
|
|
65
66
|
if (!sixb) {
|
|
66
67
|
throw new Error("[SixbServer] Execution scope is not available for this route.")
|
|
67
68
|
}
|
|
68
69
|
return sixb
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The caller the auth guard resolved for this request. Null on public routes, for shared-access and
|
|
74
|
+
* agent-gateway requests, and when auth is disabled.
|
|
75
|
+
*/
|
|
76
|
+
export function requestCaller(context: unknown): AuthenticatedRequestAuthSession | null {
|
|
77
|
+
const auth = (context as { readonly auth?: ServerAuthGuardDecision }).auth
|
|
78
|
+
return auth?.kind === "allow" ? auth.session : null
|
|
79
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto"
|
|
2
2
|
import type { SixbHostView } from "@sixb/core"
|
|
3
3
|
import {
|
|
4
|
-
CSRF_HEADER_NAME,
|
|
5
4
|
generateCsrfToken,
|
|
6
5
|
getCookie,
|
|
7
6
|
isCsrfExemptMethod,
|
|
@@ -95,7 +94,6 @@ export class SharedAccessBoundary {
|
|
|
95
94
|
!isCsrfExemptMethod(request.method) &&
|
|
96
95
|
!verifyDoubleSubmitCsrf(request, {
|
|
97
96
|
cookieName: sharedCookieNames(selectedGrantId).csrf,
|
|
98
|
-
headerName: CSRF_HEADER_NAME,
|
|
99
97
|
})
|
|
100
98
|
) {
|
|
101
99
|
return { kind: "deny", response: sharedAccessForbiddenResponse() }
|
|
@@ -182,7 +180,6 @@ export class SharedAccessBoundary {
|
|
|
182
180
|
if (
|
|
183
181
|
!verifyDoubleSubmitCsrf(request, {
|
|
184
182
|
cookieName: sharedCookieNames(grantId).csrf,
|
|
185
|
-
headerName: CSRF_HEADER_NAME,
|
|
186
183
|
})
|
|
187
184
|
) {
|
|
188
185
|
return { kind: "csrf" }
|
package/src/openapi/security.ts
CHANGED
|
@@ -2,25 +2,37 @@ import { CSRF_HEADER_NAME } from "@sixb/core/internal/auth"
|
|
|
2
2
|
import { SHARED_ACCESS_GRANT_HEADER_NAME } from "../auth/shared-access"
|
|
3
3
|
|
|
4
4
|
export const SIXB_CSRF_SECURITY_SCHEME_ID = "sixbCsrf"
|
|
5
|
-
export const
|
|
5
|
+
export const SIXB_SESSION_SECURITY_SCHEME_ID = "sixbSession"
|
|
6
|
+
export const SIXB_ACCESS_TOKEN_SECURITY_SCHEME_ID = "sixbAccessToken"
|
|
6
7
|
export const SIXB_SHARED_GRANT_SECURITY_SCHEME_ID = "sixbSharedGrant"
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
]
|
|
9
|
+
const csrf = { [SIXB_CSRF_SECURITY_SCHEME_ID]: [] as string[] }
|
|
10
|
+
const session = { [SIXB_SESSION_SECURITY_SCHEME_ID]: [] as string[] }
|
|
11
|
+
const accessToken = { [SIXB_ACCESS_TOKEN_SECURITY_SCHEME_ID]: [] as string[] }
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[SIXB_BEARER_SECURITY_SCHEME_ID]: [] as string[],
|
|
17
|
-
},
|
|
18
|
-
]
|
|
13
|
+
// A browser session is its cookie, which OpenAPI leaves implicit: reads need nothing more, and
|
|
14
|
+
// mutations add the CSRF header. A native client's session is its bearer access token instead.
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
/** The default for every operation: any session. Public operations override it with `[]`. */
|
|
17
|
+
export const SIXB_SESSION_SECURITY_REQUIREMENT = [session]
|
|
18
|
+
|
|
19
|
+
/** A mutation taking a session: a browser's with its CSRF token, or a native client's. */
|
|
20
|
+
export const SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT = [csrf, session]
|
|
21
|
+
|
|
22
|
+
// Public routes that still act for a session when one is sent list `{}`, meaning "or nothing", so
|
|
23
|
+
// generated clients send their credentials instead of omitting them.
|
|
24
|
+
|
|
25
|
+
/** Who-am-I: answers anyone, and describes the session when one is sent. */
|
|
26
|
+
export const SIXB_OPTIONAL_SESSION_SECURITY_REQUIREMENT = [session, {}]
|
|
27
|
+
|
|
28
|
+
/** Sign-out: succeeds for anyone, and ends the session when one is sent. */
|
|
29
|
+
export const SIXB_OPTIONAL_SESSION_MUTATION_SECURITY_REQUIREMENT = [csrf, session, {}]
|
|
30
|
+
|
|
31
|
+
/** A read that also accepts a personal or service-account access token. */
|
|
32
|
+
export const SIXB_ACCESS_TOKEN_READ_SECURITY_REQUIREMENT = [accessToken, session]
|
|
33
|
+
|
|
34
|
+
/** A mutation that also accepts a personal or service-account access token. */
|
|
35
|
+
export const SIXB_ACCESS_TOKEN_MUTATION_SECURITY_REQUIREMENT = [csrf, accessToken, session]
|
|
24
36
|
|
|
25
37
|
export const SIXB_SHARED_READ_SECURITY_REQUIREMENT = {
|
|
26
38
|
[SIXB_SHARED_GRANT_SECURITY_SCHEME_ID]: [] as string[],
|
|
@@ -39,12 +51,20 @@ export const SIXB_CSRF_SECURITY_SCHEME = {
|
|
|
39
51
|
"Required for cookie-authenticated mutating requests. Use the csrfToken returned by the corresponding session endpoint.",
|
|
40
52
|
} as const
|
|
41
53
|
|
|
42
|
-
export const
|
|
54
|
+
export const SIXB_SESSION_SECURITY_SCHEME = {
|
|
55
|
+
type: "http",
|
|
56
|
+
scheme: "bearer",
|
|
57
|
+
bearerFormat: "Sixb session access token",
|
|
58
|
+
description:
|
|
59
|
+
"A signed-in native client's session access token, from device login and renewed through /api/auth/refresh. Accepted wherever a browser session is; browsers authenticate with the session cookie instead.",
|
|
60
|
+
} as const
|
|
61
|
+
|
|
62
|
+
export const SIXB_ACCESS_TOKEN_SECURITY_SCHEME = {
|
|
43
63
|
type: "http",
|
|
44
64
|
scheme: "bearer",
|
|
45
65
|
bearerFormat: "Sixb access token",
|
|
46
66
|
description:
|
|
47
|
-
"
|
|
67
|
+
"A personal access token or service-account token, for scripts and services. Accepted only on routes that document this scheme. A native client's session token uses sixbSession instead.",
|
|
48
68
|
} as const
|
|
49
69
|
|
|
50
70
|
export const SIXB_SHARED_GRANT_SECURITY_SCHEME = {
|
|
@@ -2,7 +2,7 @@ import type { SixbHostView } from "@sixb/core"
|
|
|
2
2
|
import type { ActionRunRecord } from "@sixb/core/storage"
|
|
3
3
|
import type { Elysia } from "elysia"
|
|
4
4
|
import { z } from "zod"
|
|
5
|
-
import {
|
|
5
|
+
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
6
6
|
import { requireRequestSixb } from "../auth/scope"
|
|
7
7
|
import {
|
|
8
8
|
createContextualFileContentResponse,
|
|
@@ -168,7 +168,7 @@ export function registerActionRunRoutes(app: Elysia, host: SixbHostView) {
|
|
|
168
168
|
summary: "List action run history",
|
|
169
169
|
tags: [OPENAPI_TAGS.actionRuns.name],
|
|
170
170
|
operationId: "listActionRuns",
|
|
171
|
-
security:
|
|
171
|
+
security: accessTokenSecurityRequirement("listActionRuns"),
|
|
172
172
|
},
|
|
173
173
|
}
|
|
174
174
|
)
|
|
@@ -206,7 +206,7 @@ export function registerActionRunRoutes(app: Elysia, host: SixbHostView) {
|
|
|
206
206
|
summary: "Get action run detail",
|
|
207
207
|
tags: [OPENAPI_TAGS.actionRuns.name],
|
|
208
208
|
operationId: "getActionRun",
|
|
209
|
-
security:
|
|
209
|
+
security: accessTokenSecurityRequirement("getActionRun"),
|
|
210
210
|
},
|
|
211
211
|
}
|
|
212
212
|
)
|
|
@@ -221,7 +221,7 @@ export function registerActionRunRoutes(app: Elysia, host: SixbHostView) {
|
|
|
221
221
|
summary: "Get action run file content",
|
|
222
222
|
tags: ["Actions"],
|
|
223
223
|
operationId: "getActionRunFileContent",
|
|
224
|
-
security:
|
|
224
|
+
security: accessTokenSecurityRequirement("getActionRunFileContent"),
|
|
225
225
|
responses: fileContentGetResponses({ optionalStorage: true }),
|
|
226
226
|
},
|
|
227
227
|
}
|
|
@@ -237,7 +237,7 @@ export function registerActionRunRoutes(app: Elysia, host: SixbHostView) {
|
|
|
237
237
|
summary: "Head action run file content",
|
|
238
238
|
tags: ["Actions"],
|
|
239
239
|
operationId: "headActionRunFileContent",
|
|
240
|
-
security:
|
|
240
|
+
security: accessTokenSecurityRequirement("headActionRunFileContent"),
|
|
241
241
|
responses: fileContentHeadResponses({ optionalStorage: true }),
|
|
242
242
|
},
|
|
243
243
|
}
|
package/src/routes/actions.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ActionDescriptor, SixbHostView } from "@sixb/core"
|
|
2
2
|
import { schemaFieldsToJsonSchema } from "@sixb/core/internal/ontology"
|
|
3
3
|
import type { Elysia } from "elysia"
|
|
4
|
-
import {
|
|
4
|
+
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
5
5
|
import { requireRequestSixb } from "../auth/scope"
|
|
6
6
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
7
7
|
import {
|
|
@@ -62,7 +62,7 @@ export function registerActionRoutes(app: Elysia, host: SixbHostView) {
|
|
|
62
62
|
summary: "List registered actions",
|
|
63
63
|
tags: [OPENAPI_TAGS.actions.name],
|
|
64
64
|
operationId: "listActions",
|
|
65
|
-
security:
|
|
65
|
+
security: accessTokenSecurityRequirement("listActions"),
|
|
66
66
|
},
|
|
67
67
|
}
|
|
68
68
|
)
|
|
@@ -85,7 +85,7 @@ export function registerActionRoutes(app: Elysia, host: SixbHostView) {
|
|
|
85
85
|
summary: "Get action metadata",
|
|
86
86
|
tags: [OPENAPI_TAGS.actions.name],
|
|
87
87
|
operationId: "getAction",
|
|
88
|
-
security:
|
|
88
|
+
security: accessTokenSecurityRequirement("getAction"),
|
|
89
89
|
},
|
|
90
90
|
}
|
|
91
91
|
)
|
|
@@ -123,7 +123,7 @@ export function registerActionRoutes(app: Elysia, host: SixbHostView) {
|
|
|
123
123
|
summary: "Request an action",
|
|
124
124
|
tags: [OPENAPI_TAGS.actions.name],
|
|
125
125
|
operationId: "requestAction",
|
|
126
|
-
security:
|
|
126
|
+
security: accessTokenSecurityRequirement("requestAction"),
|
|
127
127
|
},
|
|
128
128
|
}
|
|
129
129
|
)
|