@krak-stack/auth 0.2.24 → 0.2.25

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @krak-stack/auth
2
2
 
3
+ ## 0.2.25
4
+
5
+ ### Patch Changes
6
+
7
+ - Require `@krak-stack/registry` version `^0.1.52` for the coordinated audit attribution and telemetry integration.
8
+
9
+ - Actor authorization adds standard `user.roles` from the current organization membership for historical audit snapshots, without confusing global roles or organization API keys with human members. Auth emits IDs and roles only, not names/photos. Clear inherited profile/role annotations alongside other auth attribution. Audit display names/photos are resolved dynamically from current organization membership.
10
+
11
+ Separate the responsible principal (`app.actor.type/id`, user or organization) from authentication (`app.auth.method`, session or api_key) and API-key record identity (`app.auth.credential.id`). Replace inherited authentication annotations together with actor annotations; never emit credentials or session tokens.
12
+
13
+ Emit `app.auth.impersonator.id` from a verified session's `impersonatedBy`, preserving the effective user's actor ID. Keep organization impersonation route restrictions unchanged and clear stale impersonator annotations for ordinary or anonymous requests.
14
+
15
+ - 32213bb: Add verified actor type/ID and API-key owner type/ID to AuthMiddleware log and span annotations, preserving existing user and organization attribution. Distinguish API-key principals from their owners without emitting credentials or changing the authentication model. This enables audit recording through inherited telemetry context; MCP and AI context remain integration-owned.
16
+
17
+ Replace the complete auth-owned annotation set so organization keys cannot inherit stale user IDs and users cannot inherit API-key owners. Preserve unrelated annotations and restore scoped log/child-span context after the handler. Clear stale fields on the already-created current span using empty strings because the tracer interface does not expose attribute removal.
18
+
19
+ Provide the same optional authentication and attribution for plain HttpRouter routes through AuthMiddleware.routerLayer, with optional exact-path scoping. Anonymous requests clear inherited attribution; auth service failures remain explicit. ActorRequired continues to own project authorization and CurrentActor without reconstructing telemetry attribution.
20
+
3
21
  ## 0.2.24
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -74,7 +74,7 @@ import { Layer } from "effect";
74
74
 
75
75
  const telemetry = HttpApiOtlp.layer.pipe(
76
76
  Layer.provide(AuthMiddleware.routerLayer({ paths: ["/api/otel/v1/logs"] })),
77
- Layer.provide(Events.processorLayer),
77
+ Layer.provide(Events.ingestionLayer),
78
78
  Layer.provide(eventsLayer),
79
79
  );
80
80
  ```
@@ -122,16 +122,18 @@ Define project permissions with `defineProjectAccess`, resolve actors with `Acto
122
122
 
123
123
  `AuthMiddleware` annotates the current span, child spans and handler logs with verified attribution:
124
124
 
125
- | Attribute | User session | User-owned API key | Organization-owned API key |
126
- | ---------------------- | ---------------------- | ---------------------- | -------------------------- |
127
- | `app.actor.type` | `user` | `api_key` | `api_key` |
128
- | `app.actor.id` | User ID | API-key ID | API-key ID |
129
- | `app.actor.owner.type` | Omitted | `user` | `organization` |
130
- | `app.actor.owner.id` | Omitted | Owner user ID | Owner organization ID |
131
- | `user.id` | User ID | Owner user ID | Omitted |
132
- | `organization.id` | Active organization ID | Active organization ID | Owner organization ID |
125
+ | Attribute | User session | User-owned API key | Organization-owned API key |
126
+ | -------------------------- | -------------------------------------- | -------------------------- | -------------------------- |
127
+ | `app.actor.type` | `user` | `user` | `organization` |
128
+ | `app.actor.id` | User ID | Owner user ID | Owner organization ID |
129
+ | `app.auth.method` | `session` | `api_key` | `api_key` |
130
+ | `app.auth.credential.id` | Omitted | API-key record ID | API-key record ID |
131
+ | `app.auth.impersonator.id` | Initiating admin ID when impersonating | Omitted | Omitted |
132
+ | `user.id` | User ID | Owner user ID | Omitted |
133
+ | `user.roles` | Organization roles | Owner's organization roles | Empty array |
134
+ | `organization.id` | Active organization ID | Active organization ID | Owner organization ID |
133
135
 
134
- The `app.actor.*` fields and existing `organization.id` are application conventions, not standard OTel actor attributes. The public actor model still uses `type: "apiKey"`; `api_key` is its telemetry representation. Only identifiers are emitted, never API-key values or session tokens. Consumers such as transactional audit recording can inherit these log annotations without depending on the auth SDK. MCP and AI execution context belongs to the respective integration layers and does not replace the authenticated actor.
136
+ `user.id` and `user.roles` follow OpenTelemetry user semantic conventions. Roles are added by `ActorRequired`, not session-only router middleware. Names, photos, email addresses, API-key values, and session tokens are not emitted. OTel defines `user.name` as login/username and `user.full_name` as full name; neither is needed for attribution here. The `app.actor.*`, `app.auth.*` and existing `organization.id` fields are application conventions. The public authorization model still uses `type: "apiKey"`, but telemetry identifies its owning user or organization as the responsible principal and records the key separately as a credential. This replaces the previous `app.actor.owner.*` fields and API-key actor IDs; telemetry consumers must migrate together with the SDK. Audit consumers resolve current names/photos from organization membership for display, rather than copying them into logs. MCP and AI execution context belongs to the respective integration layers and does not replace the authenticated actor.
135
137
 
136
138
  Auth-owned user, organization and actor annotations replace the inherited set,
137
139
  preventing stale user/API-key owner attribution. Unrelated request, MCP and agent
@@ -140,10 +142,12 @@ Stale fields on an already-created current span are cleared to empty strings
140
142
  because the tracer interface has no attribute-removal method; handler logs and
141
143
  new child spans omit those fields entirely.
142
144
 
143
- `ActorRequired` does not construct or rewrite attribution. It resolves the project
144
- actor, enforces actor constraints, and provides `CurrentActor`, preserving the
145
- annotations established by `AuthMiddleware`. When supplying `AuthService` directly
146
- without `AuthMiddleware`, authorization still works, but no auth attribution is
147
- added automatically.
145
+ `ActorRequired` resolves the project actor, enforces actor constraints, and provides
146
+ `CurrentActor`. It adds `user.roles` to logs and spans from the verified active
147
+ organization membership, not the global user role. Events recorded in the handler
148
+ retain that role snapshot even after membership changes. Session-only router
149
+ middleware does not look up roles. When supplying `AuthService` directly without
150
+ `AuthMiddleware`, only the verified roles are added; session profile/actor
151
+ attribution still requires `AuthMiddleware`.
148
152
 
149
153
  See the [RBAC guide](https://auth.krakstack.net/en/docs/rbac).