@ankhorage/infra-cerbos 0.2.1 → 0.2.3
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 +2 -2
- package/dist/constants/infra.d.ts +1 -1
- package/dist/features/authorization-infrastructure/application/createCerbosWorkload.d.ts.map +1 -1
- package/dist/features/authorization-infrastructure/application/createCerbosWorkload.js +12 -14
- package/dist/features/authorization-infrastructure/application/createCerbosWorkload.js.map +1 -1
- package/dist/features/authorization-infrastructure/composition/createInfraAdapter.js +3 -3
- package/dist/features/authorization-infrastructure/composition/createInfraAdapter.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<!-- markdownlint-disable MD013 MD033 -->
|
|
2
2
|
<!-- This file is generated by Paradox. Do not edit manually. -->
|
|
3
3
|
|
|
4
|
-
# @ankhorage/cerbos
|
|
4
|
+
# @ankhorage/infra-cerbos
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Cerbos authorization service adapter for provider-neutral Ankhorage infrastructure.
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Canonical Contracts-backed identity used for adapter discovery and conformance. */
|
|
2
2
|
export declare const infraAdapterDescriptor: {
|
|
3
3
|
readonly id: "cerbos";
|
|
4
|
-
readonly package: "@ankhorage/cerbos";
|
|
4
|
+
readonly package: "@ankhorage/infra-cerbos";
|
|
5
5
|
readonly kind: "service";
|
|
6
6
|
readonly configVersion: 1;
|
|
7
7
|
readonly capabilities: readonly ["authz"];
|
package/dist/features/authorization-infrastructure/application/createCerbosWorkload.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCerbosWorkload.d.ts","sourceRoot":"","sources":["../../../../src/features/authorization-infrastructure/application/createCerbosWorkload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createCerbosWorkload.d.ts","sourceRoot":"","sources":["../../../../src/features/authorization-infrastructure/application/createCerbosWorkload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAWpC,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CA4BtF"}
|
|
@@ -8,24 +8,22 @@ storage:
|
|
|
8
8
|
`;
|
|
9
9
|
/** Project Cerbos config and policy intent into one runtime-neutral workload. */
|
|
10
10
|
export function createCerbosWorkload(context) {
|
|
11
|
-
const policies = context.desired.authz?.provider === 'cerbos' ? context.desired.authz.policies :
|
|
11
|
+
const policies = context.desired.authz?.provider === 'cerbos' ? (context.desired.authz.policies ?? {}) : {};
|
|
12
|
+
const policyFiles = Object.entries(policies)
|
|
13
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
14
|
+
.reduce((files, [path, content]) => ({
|
|
15
|
+
...files,
|
|
16
|
+
[`/policies/${path}`]: { kind: 'literal', value: content },
|
|
17
|
+
}), {});
|
|
12
18
|
return {
|
|
13
19
|
id: 'cerbos',
|
|
14
20
|
artifact: { kind: 'image', image: 'ghcr.io/cerbos/cerbos:0.40.0' },
|
|
15
21
|
args: ['server', '--config=/config/config.yaml'],
|
|
16
|
-
ports:
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{ path: '/config/config.yaml', content: { kind: 'literal', value: CERBOS_CONFIG } },
|
|
22
|
-
...[...(policies ?? [])]
|
|
23
|
-
.sort((left, right) => left.path.localeCompare(right.path))
|
|
24
|
-
.map(({ path, content }) => ({
|
|
25
|
-
path: `/policies/${path}`,
|
|
26
|
-
content: { kind: 'literal', value: content },
|
|
27
|
-
})),
|
|
28
|
-
],
|
|
22
|
+
ports: { http: { port: 3592 }, grpc: { port: 3593 } },
|
|
23
|
+
files: {
|
|
24
|
+
'/config/config.yaml': { kind: 'literal', value: CERBOS_CONFIG },
|
|
25
|
+
...policyFiles,
|
|
26
|
+
},
|
|
29
27
|
health: {
|
|
30
28
|
kind: 'command',
|
|
31
29
|
command: ['/cerbos', 'healthcheck', '--config=/config/config.yaml'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCerbosWorkload.js","sourceRoot":"","sources":["../../../../src/features/authorization-infrastructure/application/createCerbosWorkload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createCerbosWorkload.js","sourceRoot":"","sources":["../../../../src/features/authorization-infrastructure/application/createCerbosWorkload.ts"],"names":[],"mappings":"AAMA,MAAM,aAAa,GAAG;;;;;;;CAOrB,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,QAAQ,GACZ,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7F,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;SACzC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SACpD,MAAM,CACL,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3B,GAAG,KAAK;QACR,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE;KAC3D,CAAC,EACF,EAAE,CACH,CAAC;IACJ,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,8BAA8B,EAAE;QAClE,IAAI,EAAE,CAAC,QAAQ,EAAE,8BAA8B,CAAC;QAChD,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACrD,KAAK,EAAE;YACL,qBAAqB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE;YAChE,GAAG,WAAW;SACf;QACD,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,8BAA8B,CAAC;SACpE;QACD,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraExecutionContext,\n InfraWorkloadSpec,\n InfraWorkloadValue,\n} from '@ankhorage/contracts/infra';\n\nconst CERBOS_CONFIG = `server:\n httpListenAddr: \":3592\"\n grpcListenAddr: \":3593\"\nstorage:\n driver: \"disk\"\n disk:\n directory: /policies\n`;\n\n/** Project Cerbos config and policy intent into one runtime-neutral workload. */\nexport function createCerbosWorkload(context: InfraExecutionContext): InfraWorkloadSpec {\n const policies =\n context.desired.authz?.provider === 'cerbos' ? (context.desired.authz.policies ?? {}) : {};\n const policyFiles = Object.entries(policies)\n .sort(([left], [right]) => left.localeCompare(right))\n .reduce<Readonly<Record<string, InfraWorkloadValue>>>(\n (files, [path, content]) => ({\n ...files,\n [`/policies/${path}`]: { kind: 'literal', value: content },\n }),\n {},\n );\n return {\n id: 'cerbos',\n artifact: { kind: 'image', image: 'ghcr.io/cerbos/cerbos:0.40.0' },\n args: ['server', '--config=/config/config.yaml'],\n ports: { http: { port: 3592 }, grpc: { port: 3593 } },\n files: {\n '/config/config.yaml': { kind: 'literal', value: CERBOS_CONFIG },\n ...policyFiles,\n },\n health: {\n kind: 'command',\n command: ['/cerbos', 'healthcheck', '--config=/config/config.yaml'],\n },\n exposure: 'internal',\n replicas: 1,\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { infraAdapterDescriptor } from '../../../constants/infra';
|
|
2
|
-
import { destroyCerbos, getCerbosStatus, planCerbos, reconcileCerbos, validateCerbos, } from '../application/cerbosLifecycle';
|
|
3
|
-
import { createCerbosWorkload } from '../application/createCerbosWorkload';
|
|
1
|
+
import { infraAdapterDescriptor } from '../../../constants/infra.js';
|
|
2
|
+
import { destroyCerbos, getCerbosStatus, planCerbos, reconcileCerbos, validateCerbos, } from '../application/cerbosLifecycle.js';
|
|
3
|
+
import { createCerbosWorkload } from '../application/createCerbosWorkload.js';
|
|
4
4
|
/***
|
|
5
5
|
* Create the canonical runtime-neutral Cerbos authorization adapter.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfraAdapter.js","sourceRoot":"","sources":["../../../../src/features/authorization-infrastructure/composition/createInfraAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createInfraAdapter.js","sourceRoot":"","sources":["../../../../src/features/authorization-infrastructure/composition/createInfraAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,aAAa,EACb,eAAe,EACf,UAAU,EACV,eAAe,EACf,cAAc,GACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,UAAU,EAAE,sBAAsB;QAClC,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACpE,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC5D,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE;YACjC,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;YAC3C,OAAO,OAAO,CAAC,OAAO,CACpB,UAAU,CAAC,EAAE;gBACX,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;gBACvE,CAAC,CAAC,UAAU,CACf,CAAC;QACJ,CAAC;QACD,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACtE,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACnE,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACrF,CAAC;AACJ,CAAC","sourcesContent":["import type { InfraServiceAdapter } from '@ankhorage/contracts/infra';\n\nimport { infraAdapterDescriptor } from '../../../constants/infra.js';\nimport {\n destroyCerbos,\n getCerbosStatus,\n planCerbos,\n reconcileCerbos,\n validateCerbos,\n} from '../application/cerbosLifecycle.js';\nimport { createCerbosWorkload } from '../application/createCerbosWorkload.js';\n\n/***\n * Create the canonical runtime-neutral Cerbos authorization adapter.\n *\n * Cerbos contributes one portable workload plus policy files. The selected runtime owns their\n * concrete materialization; this provider contains no Kubernetes or Compose branches.\n *\n * @readme\n */\nexport function createInfraAdapter(): InfraServiceAdapter {\n return {\n descriptor: infraAdapterDescriptor,\n validateAsync: (context) => Promise.resolve(validateCerbos(context)),\n planAsync: (context) => Promise.resolve(planCerbos(context)),\n desiredWorkloadsAsync: (context) => {\n const validation = validateCerbos(context);\n return Promise.resolve(\n validation.ok\n ? { ok: true, value: [createCerbosWorkload(context)], diagnostics: [] }\n : validation,\n );\n },\n reconcileAsync: (context) => Promise.resolve(reconcileCerbos(context)),\n statusAsync: (context) => Promise.resolve(getCerbosStatus(context)),\n destroyAsync: (context, request) => Promise.resolve(destroyCerbos(context, request)),\n };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Public Cerbos authorization adapter package boundary. */
|
|
2
|
-
export { infraAdapterDescriptor } from './constants/infra';
|
|
3
|
-
export { createInfraAdapter } from './features/authorization-infrastructure/composition/createInfraAdapter';
|
|
2
|
+
export { infraAdapterDescriptor } from './constants/infra.js';
|
|
3
|
+
export { createInfraAdapter } from './features/authorization-infrastructure/composition/createInfraAdapter.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Public Cerbos authorization adapter package boundary. */
|
|
2
|
-
export { infraAdapterDescriptor } from './constants/infra';
|
|
3
|
-
export { createInfraAdapter } from './features/authorization-infrastructure/composition/createInfraAdapter';
|
|
2
|
+
export { infraAdapterDescriptor } from './constants/infra.js';
|
|
3
|
+
export { createInfraAdapter } from './features/authorization-infrastructure/composition/createInfraAdapter.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC","sourcesContent":["/** Public Cerbos authorization adapter package boundary. */\nexport { infraAdapterDescriptor } from './constants/infra.js';\nexport { createInfraAdapter } from './features/authorization-infrastructure/composition/createInfraAdapter.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/infra-cerbos",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Cerbos authorization service adapter for provider-neutral Ankhorage infrastructure.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"typecheck": "bun x tsc --noEmit -p tsconfig.json",
|
|
44
44
|
"check-types": "bun run typecheck",
|
|
45
45
|
"test": "bun test src",
|
|
46
|
+
"test:packed-consumer": "bun consumer-tests/packedConsumer.ts",
|
|
46
47
|
"docs": "paradox && ankhorage-prettier --write README.md paradox",
|
|
47
48
|
"prepack": "bun run build",
|
|
48
49
|
"lint": "ankhorage-eslint . --max-warnings=0",
|
|
@@ -55,10 +56,10 @@
|
|
|
55
56
|
"version-packages": "ankhorage-changeset version"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@ankhorage/contracts": "^
|
|
59
|
+
"@ankhorage/contracts": "^26.2.2"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
|
-
"@ankhorage/devtools": "^
|
|
62
|
+
"@ankhorage/devtools": "^2.3.30",
|
|
62
63
|
"@ankhorage/paradox": "^0.1.24",
|
|
63
64
|
"@types/bun": "^1.4.2",
|
|
64
65
|
"@types/node": "^26.4.1",
|