skillhub/openspec/changes/split-api-token-skill-capabilities/bundle-authorization-inventory.md
小妍儿 ✨ 3ee80f996b
feat(auth): split API token skill capabilities (#1049) (#1078)
* docs(openspec): propose split API token skill capabilities

Define five token capabilities (read, submit, publish-private, manage,
delete), the route mapping, combined-operation limits, token minting
limits, legacy token and CLI compatibility, and negative test design.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>

* docs(openspec): clarify token compatibility and bundle snapshot boundaries

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(auth): inventory Bundle authorization provenance

Record persisted evidence and fail-closed recovery rules before implementing snapshots.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(auth): split token capabilities and classify route policies

Preserve Suite deletion authorization and verify legacy route compatibility against the original ordered catalog.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(auth): enforce token ceilings on combined skill operations

Persist Bundle initiator capability snapshots and fail closed on unknown historical authority during recovery and retry.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(auth): bound token issuance and expose effective capabilities

Validate requested scopes and expiry before rotation or extension. Expose capability discovery and machine-readable authorization errors without broadening token privileges.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(tokens): add Web capability presets and CLI authorization guidance

Issue candidate-only login tokens, display effective capabilities and legacy compatibility, and require explicit delete authorization without automatic reissuance. Verify real HTTP candidate and legacy publication flows.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(auth): document token capabilities and upgrade boundaries

Describe bounded issuance, compatibility aliases, CLI delete authorization, administrator upload changes, fail-closed Bundle recovery and the omitted-scopes deprecation schedule.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(auth): align capability action boundaries

Document manage authorization for review withdrawal and keep DTO imports formatted with backend conventions.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(publish): limit visibility ceiling check to token calls

Session uploads keep their previous path, and a missing locked row no longer raises a null pointer before the existing visibility checks run.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): preserve rerelease ceilings and explain bundle blocks

Carry token capabilities through rerelease and resolve visibility under the publication lock. Localize permanent Bundle authorization failures and hide ineffective retry actions.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): classify main's public routes and renumber bundle snapshot migration

main added public GET site-presentation routes and its own V122 migration. Record the new routes in the catalog baseline as unchanged public routes and move the Bundle authorization snapshot to V123.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(site): pin presentation upgrade check to V122

The upgrade test counted every migration after V121; with the Bundle snapshot now at V123 it saw two. Target V122 so it keeps checking only the presentation seed.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): compare token expiry ceilings at stored precision

Token expiry is stored at microsecond precision. On Linux CI Instant.now() carries nanoseconds, so a child token asking for exactly its parent's expiry compared as later and was rejected. Truncate requested expiry to microseconds before the ceiling check.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): renumber bundle snapshot migration after main's V123

main 22409aba added V123__homepage_recommendations. Move the Bundle authorization snapshot to V124 and record main's public site-recommendations routes in the token catalog baseline as unchanged public routes.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(auth): keep built-in skill sync out of token flow side-effect checks

Since main 22409aba the built-in skill sync can publish after startup, asynchronously, and its storage writes landed inside the 'denied rerelease writes nothing' assertion on CI. Disable built-in sync for this test class, as other integration tests already do.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): block bundle recovery with unknown authorization

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
(cherry picked from commit cb8fb05d77d4b455032cbc2d3a1fdc2dd7bce894)
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* feat(web): redesign token credentials and compact permission controls

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
(cherry picked from commit acd3615ee57a4bb432980601bb883a1a86906d1a)
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* chore(web): regenerate API types from integrated backend

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* fix(web): complete token locales and static analytics markers

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* test(auth): preserve operation-level bundle authorization errors

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

---------

Signed-off-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
Co-authored-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>
Co-authored-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-11-16 11:02:38 +08:00

61 lines
4 KiB
Markdown

# Bundle historical authorization evidence inventory
Baseline: `a3dc2c4aa3de6c81c8332d1e133d31a0e907e4b9`.
This is a source/schema inventory, not an inspection of production data.
## Persisted evidence
- V54 creates `skill_suite_bundle_operation`: operation ID, preview token, client request ID,
actor ID, target coordinates, reservation, archive digest/key, plan JSON, warning digest,
status/failure/result IDs, timestamps and optimistic lock version.
`SkillSuiteBundleExecutionOperation` maps these fields. There is no initiator type,
API token ID, scope snapshot or persisted authorization decision.
- V54 preview rows contain actor ID, manifest/plan JSON, archive metadata, warning digest,
expiration and confirmation timestamps. Preview `token` identifies a preview, not an API token.
- V54 member results link operation ID to coordinates, requested visibility/version,
planned action, fingerprints, result IDs, errors/warnings and status. They contain no
initiating authentication information.
- V55 adds staged-object cleanup metadata; V58 and V59 add actor/status/history indexes.
No later migration in this checkout adds Bundle authorization provenance.
- `SkillSuiteBundleConfirmationAppService.confirm` receives actor ID and account/namespace
roles. It persists the operation and member plan, marks the preview confirmed and emits
`SkillSuiteBundleAdvanceRequestedEvent`. It does not write an audit record recording
operation ID together with authentication type, token identity or scopes.
- `SkillSuiteBundleController` extracts user ID and platform/namespace roles, not token
authentication metadata. `Idempotency-Key` is a caller-supplied request identifier, not
evidence of token authentication.
## Audit and authentication records
- `audit_log` (V1, V6, V7, V42, V61; `AuditLog`, `AuditLogService`) stores actor, action,
target type/numeric ID, request ID, client IP, user agent, details and time. V61 adds
organization ID, string target reference and result. These columns could support a
future linked record, but the Bundle confirmation/execution writers do not produce one.
- Skill/Suite lifecycle audit entries describe resource operations. Neither actor identity
nor a resource ID proves how a particular Bundle operation was authorized.
- `api_token` stores current scope JSON, user/subject identity, token prefix/hash,
expiration, revocation and last use. No Bundle foreign key or operation ID links it to
the initiating request. Last-use time cannot identify an operation or recover its scopes.
- `ApiTokenAuthenticationFilter` projects scopes into transient Spring authorities, without
persisting an operation link. `RequestLoggingFilter` logs method/path/status/timing/IP,
not authenticated token identity or scopes; ordinary logs are not authorization evidence.
- Recovery resolves current account/namespace roles through
`SkillSuiteBundleActorContextService`. Retry accepts the current caller's roles.
Neither is evidence of the original Token capability ceiling.
## Resulting implementation rule
No reliable operation-ID-linked historical initiator/scope evidence is established by this
checkout. Do not backfill authority from dates, actor roles, current tokens, request IDs,
empty snapshots or worker/retry identities.
New operations must persist an immutable explicit SESSION or TOKEN initiator; TOKEN requires
an effective-capability snapshot before insertion. Existing rows retain unknown provenance.
If an unknown-provenance operation reaches a PRIVATE confirmation step, block the member and
operation as `BLOCKED_RETRYABLE` with an explicit authorization-provenance-unknown reason,
without calling `confirmPublish` or creating a partial Suite draft. Retry/recovery must use
only the original persisted authorization. A more privileged retry cannot repair missing
historical authority; the user must create a new explicitly authorized operation.
A future historical-evidence import would require independently verified, operation-linked
records proving initiator type and original authorization. No such import is justified here.