@owlmeans/server-iam 0.1.7 → 0.1.8

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 ADDED
@@ -0,0 +1,48 @@
1
+ # @owlmeans/server-iam
2
+
3
+ One-call OIDC RP wiring and IAM gate for OwlMeans servers — `appendIam()` and the permission-asserting `makeIamGate`.
4
+
5
+ ## Overview
6
+
7
+ - `appendIam(context)` — registers the OIDC client, wrapping service, and IAM gate in a single call, replacing verbose manual wiring
8
+ - `makeIamGate()` — produces a guard that asserts unscoped or resource-scoped permissions against the IAM backend (claims-first, UMA2 fallback)
9
+ - Re-exports `hasPermission` from `@owlmeans/iam` for inline permission checks
10
+ - Designed for IAM consumers such as the viable target template backend
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ bun add @owlmeans/server-iam
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```typescript
21
+ import { appendIam, makeIamGate } from '@owlmeans/server-iam'
22
+ import { IAM_GATE } from '@owlmeans/server-iam'
23
+
24
+ // Wire IAM into a server context
25
+ appendIam(context)
26
+
27
+ // Gate a module with a permission check
28
+ module.gate(IAM_GATE, { permission: 'manage-users' })
29
+ ```
30
+
31
+ Requires `@owlmeans/oidc` OIDC shared config and a running IAM provider configured via `@owlmeans/server-oidc-rp`.
32
+
33
+ <!-- owlmeans:agent-guidance:start -->
34
+ ## Agent guidance
35
+
36
+ This package ships embedded Claude Code skills and GitHub Copilot instructions under
37
+ `agent-meta/`. After installing your `@owlmeans/*` packages, run the OwlMeans
38
+ agent-skills installer to place them into your project's native locations
39
+ (`.claude/skills/` and `.github/instructions/`):
40
+
41
+ ```sh
42
+ npx @owlmeans/agent-skills
43
+ ```
44
+
45
+ The embedded files are version-matched to this package release. Do not edit them
46
+ directly — they are regenerated on each publish. To contribute guidance edits,
47
+ open a PR against the source monorepo.
48
+ <!-- owlmeans:agent-guidance:end -->
@@ -0,0 +1,63 @@
1
+ ---
2
+ description: "How to use @owlmeans/server-iam — one-call OIDC RP wiring (appendIam) and the IAM gate that asserts unscoped and resource-scoped permissions (claims-first, UMA2 fallback). Use when gating server endpoints in IAM consumers (e.g. the viable target template backend)."
3
+ applyTo: "**/owlmeans.ts, **/gate*.ts, **/auth-guard*.ts"
4
+ ---
5
+ <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
6
+
7
+ # Using `@owlmeans/server-iam`
8
+
9
+ Boilerplate-less server-side consumer of the OwlMeans IAM. One call wires the OIDC RP stack and the
10
+ IAM gate; the consumer never knows which IAM backend (Keycloak or integrated) is active.
11
+
12
+ ## Public API surface
13
+
14
+ | Symbol | Kind | Purpose |
15
+ |--------|------|---------|
16
+ | `appendIam(context)` | fn | Registers `makeOidcClientService()`, `makeOidcWrappingService()`, `makeIamGate()` (under `OIDC_GATE`), and the OIDC guard |
17
+ | `makeIamGate(alias?)` | fn | The IAM `GateService` — claims-first assertion with UMA2 fallback |
18
+ | `parseGateParam(param)` | fn | Splits `'perm@requestParam'` into `{ permission, resourceParam? }` |
19
+ | `RESOURCE_PARAM_SEPARATOR` | const | `'@'` |
20
+ | `hasPermission` | fn | Re-export from `@owlmeans/iam` |
21
+
22
+ ## Gate-param syntax
23
+
24
+ ```
25
+ <permission> → unscoped (project-wide): 'article--modify'
26
+ <permission>@<requestParam> → resource-scoped: 'department--modify@departmentId'
27
+ ```
28
+
29
+ - `{entity}` substitution applies to the permission part in both forms.
30
+ - For the resource-scoped form the gate resolves `req.params[requestParam] ?? req.query[requestParam]`
31
+ at assert time and requires the grant's `resources[]` to contain it (an unscoped grant always passes).
32
+ - Params are **any-of**: one granted param is enough.
33
+
34
+ ```ts
35
+ // module declaration
36
+ gate(OIDC_GATE, ['department--modify@depId'])
37
+
38
+ // or imperative
39
+ await ctx.service<GateService>(OIDC_GATE).assert(req, res, ['article--modify'])
40
+ ```
41
+
42
+ ## How the gate decides
43
+
44
+ 1. `req.auth == null` → `AuthForbidden('auth')`.
45
+ 2. **Claims mode** — when `req.auth.permissions` is a valid `PermissionSet[]` (minted into the id_token
46
+ by the integrated IAM provider and mapped into `Auth` by `@owlmeans/server-oidc-rp`), params are
47
+ asserted locally via `hasPermission`.
48
+ 3. **Fallback** — otherwise `@…` suffixes are stripped and the check delegates to the UMA2 gate model
49
+ from `@owlmeans/server-oidc-rp` (`createGateModel().loadPermissions`) — byte-equivalent to the old
50
+ `makeOidcGate`, which keeps Keycloak-backed deployments unchanged.
51
+
52
+ ## Rules
53
+
54
+ - Register the gate via `appendIam()`; do not also register `makeOidcGate()` — both use the
55
+ `OIDC_GATE` alias and the IAM gate already covers the UMA2 path.
56
+ - Never branch on the IAM backend in consumer code — the gate's claims/fallback split is the only seam.
57
+ - The OIDC provider entry must request the `permissions` scope (`extraScopes`) for claims mode to
58
+ engage; without it the gate transparently uses the fallback.
59
+
60
+ ## Related instructions
61
+
62
+ - `@owlmeans/iam` — abstraction + `hasPermission`; see `iam.instructions.md`
63
+ - `@owlmeans/server-oidc-rp` — claim extraction + UMA2 model; see `server-oidc-rp.instructions.md`
@@ -0,0 +1,16 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "package": "@owlmeans/server-iam",
4
+ "version": "0.1.8",
5
+ "generatedAt": "2026-06-11T16:30:27.191Z",
6
+ "canonicalRepo": "https://github.com/owlmeans/common",
7
+ "entries": [
8
+ {
9
+ "kind": "instruction",
10
+ "name": "server-iam",
11
+ "category": "package-specific",
12
+ "file": "instructions/server-iam.instructions.md",
13
+ "canonicalPath": ".github/instructions/server-iam.instructions.md"
14
+ }
15
+ ]
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/server-iam",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -22,13 +22,13 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@owlmeans/auth": "^0.1.7",
26
- "@owlmeans/context": "^0.1.7",
27
- "@owlmeans/entrypoint": "^0.1.7",
28
- "@owlmeans/iam": "^0.1.7",
29
- "@owlmeans/oidc": "^0.1.7",
30
- "@owlmeans/server-context": "^0.1.7",
31
- "@owlmeans/server-oidc-rp": "^0.1.7"
25
+ "@owlmeans/auth": "^0.1.8",
26
+ "@owlmeans/context": "^0.1.8",
27
+ "@owlmeans/entrypoint": "^0.1.8",
28
+ "@owlmeans/iam": "^0.1.8",
29
+ "@owlmeans/oidc": "^0.1.8",
30
+ "@owlmeans/server-context": "^0.1.8",
31
+ "@owlmeans/server-oidc-rp": "^0.1.8"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@owlmeans/dep-config": "workspace:*",