# Nexus Repository REST API alignment review Reference: Sonatype Nexus Repository 3.97.0-13. The canonical machine-readable surface is the `/service/rest/swagger.json` document exposed by every Nexus instance; the endpoint list used here comes from the official `sonatype-nexus-community/nexus-repo-api-client-go` client generated from that specification. This document is an implementation reference. It records which Nexus method/path pairs exist in kkRepo at a pinned baseline, and separates that from what has actually been compared against a running Nexus. It is not a compatibility claim. ## Reference points | Role | Artifact | Revision | | --- | --- | --- | | Nexus API surface | `sonatype-nexus-community/nexus-repo-api-client-go` README, generated from the Nexus Repository 3.97.1 swagger (declared API version 3.97.0-13) | `17645c8ed520893e2515e8bd76202b537b1acc24` (client v397.97.1) | | kkRepo baseline | `klboke/kkRepo` `upstream/main` | `6b72b3f12936404f26dc065965ba073d9938e1ba` | | kkRepo reviewed head (before this correction) | `docs/nexus-rest-api-review` | `f1c801ba087296248309812737021875d24baaf7` | | kkRepo staging branch, reference only | PR #455 `feat/multi-repo-staging` head | `ef7132e4874d10a731ce36e8fbbc35760ca447b4` | The endpoint list contains 462 `/v1` method/path pairs, including the three `PATCH /v1/evaluation*` routes of the pinned client README. ## What the inventory establishes The raw table is [`nexus-rest-api-inventory.md`](nexus-rest-api-inventory.md), generated by `scripts/nexus-rest-api-inventory.py`. It answers one question: does a controller method exist whose declared path, after normalising path variables, equals the Nexus path, with the same HTTP method? It does not establish wire compatibility. A `yes` row means **method/path present**. Request and response schemas, status codes, error bodies, headers, paging tokens and permission enforcement are out of scope of the inventory. Evidence levels used below: - **present** - exact method/path match in the inventory at the baseline. No wire check. - **verified by compat-test** - a black-box `compat-test` case compares the response against a real Nexus instance. Those cases are opt-in (`NEXUS_COMPAT_BASE_URL`, `KKREPO_COMPAT_BASE_URL`, and for write paths `COMPAT_WRITE_ENABLED`); with the variables unset the case is skipped, so a green CI run alone is not evidence. - **custom** - no Nexus-shaped route; the capability exists only under `/internal/*`. - **absent** - neither a Nexus-shaped route nor a documented custom equivalent. ## Baseline and regeneration The baseline is the PR merge target, `upstream/main`, not the staging branch. Counts for the other heads are reported separately, always with their SHA. | Baseline | kkRepo SHA | method/path present | | --- | --- | ---: | | `upstream/main` (baseline) | `6b72b3f1` | 44/462 | | `docs/nexus-rest-api-review` (PR head) | `f1c801ba` | 44/462, identical matched set to main | | `feat/multi-repo-staging` (PR #455, not merged) | `ef7132e` | 52/462 | Regenerate the inventory from a git ref without checking it out: ```sh python3 scripts/nexus-rest-api-inventory.py --git-ref 6b72b3f12936404f26dc065965ba073d9938e1ba ``` The script pins the reference endpoint list to `17645c8e...`; the generated file records the resolved kkRepo SHA and the exact command in its header, so a later `main` does not silently change the published counts. The #455 contribution is the delta between two refs, computed by the same script: ```sh python3 scripts/nexus-rest-api-inventory.py \ --git-ref ef7132e4874d10a731ce36e8fbbc35760ca447b4 \ --diff-ref 6b72b3f12936404f26dc065965ba073d9938e1ba \ --output /tmp/inventory-455.md ``` which reports the eight routes listed under [kkRepo PR #455 contribution](#kkrepo-pr-455-contribution). If #455 merges, main becomes 52/462 and the baseline table above must be regenerated at the new main so the counts and the inventory stay in sync. Generator limits, so a `no` is not over-read: - only files containing `@RestController` are scanned; - only `@GetMapping`/`@PostMapping`/`@PutMapping`/`@DeleteMapping`/`@PatchMapping` with a literal path are recognised; `@RequestMapping(method = ...)`, composed annotations, `@Controller` + `@ResponseBody` and profile-gated beans are invisible; - only the first literal path of a class-level `@RequestMapping` is used; - paths are normalised (`{...}` becomes `{}`), so a differently named path variable still matches; - the reference list is the generated client README: it covers `/v1` only and carries no schemas. ## Headline (baseline `main`) - 44 of the 462 Nexus `/v1` method/path pairs are present at `6b72b3f1`. - Those 44 break down as security 34, routing rules 5, assets 2, components 1, search 1 and formats 1. No other area has a single exact match. - Security, routing rules and a few read endpoints are the only substantial Nexus-shaped surfaces. Repository management (0/218), status (0/3), blob stores (0/20), tasks/capabilities/cleanup policies/tags/system (0/35), staging/lifecycle (0/5) are absent from the Nexus surface. - Management operations exist under **custom `/internal/*` endpoints** (`/internal/repositories`, `/internal/security`, `/internal/blob-stores`, `/internal/cleanup`, `/internal/security/scanning`, `/internal/migration/nexus`). They are usable by the admin UI but cannot be called by Nexus automation. - Only asset lookup/delete/download, the `/v1/search/assets` paging edge cases, component upload and `GET /v1/formats/upload-specs` are backed by an executed comparison against Nexus, through the opt-in compat tests. Everything else is method/path presence. ## Area matrix (baseline `main`, 44/462) | Area | Nexus paths | present | Assessment | | --- | ---: | ---: | --- | | repositories | 218 | 0 | custom `/internal/repositories`; #455 adds list/get | | security | 96 | 34 | users, roles, privileges, content selectors, realms, anonymous | | blobstores | 20 | 0 | custom `/internal/blob-stores` | | iq | 11 | 0 | Nexus IQ integration, not started | | plan | 9 | 0 | not implemented | | system | 9 | 0 | no `/v1/system/*` route; status is a separate area | | tasks | 9 | 0 | Quartz runs internally, no Nexus REST view | | configuration | 7 | 0 | not implemented | | tags | 7 | 0 | not implemented | | hosted-repository-evaluation | 6 | 0 | not implemented | | script | 6 | 0 | deliberate non-goal | | search | 6 | 1 | `GET /v1/search/assets` only | | capabilities | 5 | 0 | not implemented | | cleanup-policies | 5 | 0 | custom `/internal/cleanup` | | routing-rules | 5 | 5 | present | | components | 4 | 1 | `POST /v1/components` only | | email | 4 | 0 | not implemented | | assets | 3 | 2 | get/delete; the collection route is absent | | http | 3 | 0 | not implemented | | lifecycle | 3 | 0 | not implemented | | status | 3 | 0 | #455 adds all three | | evaluation | 5 | 0 | not implemented; includes the three `PATCH /v1/evaluation*` routes | | formats | 2 | 1 | `GET /v1/formats/upload-specs` | | malicious-risk | 2 | 0 | not implemented | | recovery-mode | 2 | 0 | not implemented | | repository-dashboard | 2 | 0 | not implemented | | staging | 2 | 0 | #455 introduces session-based staging, not these legacy routes | | support | 2 | 0 | not implemented | | apikeys | 1 | 0 | not implemented | | azureblobstore | 1 | 0 | no Azure adapter | | monthly-metrics | 1 | 0 | not implemented | | repositorySettings | 1 | 0 | not implemented | | secrets | 1 | 0 | not implemented | | usage-history | 1 | 0 | not implemented | ## kkRepo PR #455 contribution #455 is not merged at the baseline. Merging it adds eight exact matches, 52/462 in total: | Method | Path | | --- | --- | | GET | `/v1/status` | | GET | `/v1/status/check` | | GET | `/v1/status/writable` | | GET | `/v1/assets` | | GET | `/v1/components` | | GET | `/v1/components/{id}` | | GET | `/v1/repositories` | | GET | `/v1/repositories/{repositoryName}` | Nothing is removed: #455 has no regression against the baseline in the inventory. ## Repositories Nexus exposes generic read/delete routes plus format/type-specific configuration. The generic namespace has no create and no update: - `GET /v1/repositories`, `GET /v1/repositories/{repositoryName}`, `GET /v1/repositorySettings` - `DELETE /v1/repositories/{repositoryName}` - the only generic write route on the repository object itself, and it works for every format; updates go through the format/type-specific path below - `POST /v1/repositories/{format}/{type}` to create, `GET|PUT /v1/repositories/{format}/{type}/{repositoryName}` to read and update; the only update path is the format/type-specific one, never a generic `PUT` - `GET /v1/repositories/{repositoryName}/browse`, `POST|DELETE .../health-check`, `POST .../invalidate-cache`, `POST .../rebuild-index`, `GET|PUT .../evaluation-settings` At the baseline kkRepo exposes none of the 218 repository paths and manages the rest through `/internal/repositories` with a kkRepo-specific payload, so Nexus Infrastructure-as-Code scripts cannot list, create, update or delete repositories. #455 adds the two generic reads (2/218). Recommendation: 1. Add `GET /v1/repositorySettings` (one route, small payload). 2. Add `DELETE /v1/repositories/{name}` backed by `RepositoryService`. This is the generic delete; there is no generic create/update to add. 3. Add format/type-specific create, read and update: `POST /v1/repositories/{format}/{type}` and `GET|PUT /v1/repositories/{format}/{type}/{name}`, with a shared envelope and per-format request records for the formats kkRepo supports (maven2, npm, pypi, go, helm, cargo, pub, composer, terraform, swift, docker, nuget, rubygems, yum, apt, alpine, r, conda, conan, ansiblegalaxy, gitlfs, raw, arch, openvsx). Do not introduce a generic `PUT /v1/repositories/{name}`: Nexus clients never call it. 4. Implement browse/health-check/invalidate-cache/rebuild-index/evaluation-settings semantics or return a documented 404/405. ## Security Present (34/96): users (list/get/create/update/delete plus change-password), user sources, roles (list/get/create/update/delete), privileges (list/get/delete plus create/update for application, wildcard, repository-admin, repository-view and repository-content-selector), content selectors (5 routes), realms active/available, anonymous. Missing (62), grouped by feature: | Feature | Missing paths | Recommendation | | --- | ---: | --- | | user tokens / service account tokens | 11 | add token CRUD; map to `api_key` infrastructure | | SAML | 10 | only if SSO is in scope | | LDAP (verify, order, cache, templates) | 11 | add verify/connection diagnostics if LDAP is supported | | Atlassian Crowd | 4 | only if Crowd is required | | OIDC / OAuth2 user mapping | 7 | map to existing OIDC realm configuration | | SSL truststore | 4 | expose existing trust configuration | | IP allowlist | 9 | implement or document as unsupported | | JWT / SSRF protection | 3 | evaluate | | `roles/assignable`, `privileges/script` | 3 | add `roles/assignable`; keep script disabled | Permissions are enforced per URL family, not per URL prefix. On `6b72b3f1`, `SecurityManagementFilter` maps a `/service/rest/v1/security/*` request to the permission expression of the matching operation: | Request family | Permission expression | | --- | --- | | `users`, `user-sources` | `nexus:users:` (`GET /user-sources` is `nexus:users:read`) | | `PUT /users/{id}/change-password` | `nexus:*` | | `roles` | `nexus:roles:` | | `privileges`, `privileges/*` | `nexus:privileges:` | | `content-selectors` | `nexus:selectors:` | | `realms/*` | `nexus:settings:read` for GET, `nexus:settings:update` otherwise | | `api-keys` | `nexus:apikey:`; `/api-keys/current*` is authenticated-only | | any other `/security/*` subpath | falls back to `nexus:settings:read` / `nexus:settings:update` | `` follows the HTTP method: GET/HEAD `read`, POST `create`, PUT/PATCH `update`, DELETE `delete`. Related families outside `/v1/security` follow the same shape: `nexus:blobstores:` for `/internal/blob-stores`, `nexus:ldap:read|update` for LDAP configuration, `nexus:security-scanning:read|update` and `nexus:security-scanning-waivers:create|delete` for scanning, `nexus:settings:read|update` for realms and UI settings, `nexus:userschangepw:create` for password changes made through the UI paths. There is no `nexus:security:*` namespace. The `/service/rest/v1/security/` URL prefix is a routing detail, not a permission domain. New endpoints must reuse the existing per-operation mapping in `SecurityManagementFilter.serviceRestPermission()`; a subpath that matches no branch falls through to `nexus:settings:read|update`, so roles that already grant the established `nexus:users:*` or `nexus:roles:*` permissions would not authorize it. Privilege identifiers and permission expressions are different namespaces. Privileges are stored with ids such as `nx-users-read` or `nx-roles-create`, and each one expands to an expression such as `nexus:users:read` (`SecurityManagementService.toPermission`). Roles reference privileges, so a role granting `nx-users-read` authorizes `nexus:users:read`. Docs, tests and new endpoints should use the expression the filter checks, never the `nx-...` id and never a made-up `nexus:security:*` family. ## Blob stores Nexus exposes 20 `/v1/blobstores/*` routes plus `POST /v1/azureblobstore/test-connection`. kkRepo has S3 and file store implementations but only custom `/internal/blob-stores` routes. Recommendation: add `/v1/blobstores/s3` and `/v1/blobstores/file` create/get/update/delete plus `DELETE /v1/blobstores/{name}` and `GET /v1/blobstores/{name}/quota-status`, mapping to the existing configuration model. Azure/Google can stay unsupported (explicit 400/404) until those adapters exist. ## Operations: tasks, capabilities, cleanup policies, tags, system - **Tasks**: expose a read-only Nexus view over the existing Quartz jobs (`GET /v1/tasks`, `GET /v1/tasks/{id}`, `POST /v1/tasks/{id}/run|stop`). Do not expose the Nexus task schema verbatim; map type/state/currentState. - **Capabilities**: only needed if capabilities are part of the product model; otherwise return a documented empty list. - **Cleanup policies**: alias `/v1/cleanup-policies` to the existing `/internal/cleanup` service with Nexus schemas. - **Tags**: Nexus component tags have no kkRepo equivalent at the baseline (Docker image tags are a different concept). Implement only if component tagging becomes a product requirement. - **System**: the Nexus `/v1/system/*` surface is EULA, license, node identity and mandatory telemetry acknowledgement (9 routes, 0 present). These are product/licensing operations with no kkRepo equivalent; document them as unsupported (404) unless one becomes an operational requirement. Status is a separate area: `GET /v1/status`, `/v1/status/check` and `/v1/status/writable` are all absent at the baseline (0/3); #455 adds all three, so that part becomes free once #455 lands or is ported. ## Search Nexus exposes `GET /v1/search` (components), `/v1/search/assets` (present), `/v1/search/assets/download`, `/v1/search/repositories`, `/v1/search/suggest` and `/v1/search/versions`. Recommendation: implement `/v1/search` and `/v1/search/repositories` first (the UI and automation use them for discovery), then `/v1/search/assets/download` (redirect to the asset `downloadUrl`). `suggest`/`versions` are optional. ## Staging and lifecycle Nexus has a legacy staging API (`POST /v1/staging/move/{destination}`, `POST /v1/staging/delete`) and a lifecycle API (`GET|PUT /v1/lifecycle/phase`, `PUT /v1/lifecycle/bounce`); none of the five routes is present at the baseline and main has no staging API at all. #455 introduces session-based staging under `/v1/staging/sessions/...`, which is not in the Nexus client list, so it does not change the count. Recommendation: keep the session API where #455 provides it and add compatibility shims for the legacy move/delete calls, or explicitly document the divergence and return 404/405. ## Components and assets At the baseline assets are 2/3 (`GET /v1/assets/{id}` and `DELETE /v1/assets/{id}` present, the `GET /v1/assets` collection route absent) and components are 1/4 (`POST /v1/components` only). #455 adds `GET /v1/assets`, `GET /v1/components` and `GET /v1/components/{id}`, taking the pair to 6/7. The only route still missing after #455 is `DELETE /v1/components/{id}`; adding it requires defining per-format deletion semantics (asset cascade vs explicit protection), reusing the existing blob-reference and cleanup-policy guards. Two compat tests cover this area when pointed at a Nexus instance: - `NexusAssetManagementBlackBoxCompatibilityTest`: raw upload through `POST /v1/components`, then asset lookup by path, `GET /v1/assets/{id}`, download and HEAD through `downloadUrl`, `DELETE /v1/assets/{id}`, 404 after delete, 422 for a malformed asset id, and an empty page for an unknown repository on `/v1/search/assets`. Requires `COMPAT_WRITE_ENABLED=true` and a disposable Raw hosted repository configured on both endpoints. - `ComponentUploadBlackBoxCompatibilityTest`: `GET /v1/formats/upload-specs` and the upload round trip, including the multipart `POST /v1/components` contract. Both are skipped when the reference URL is not configured, so they are reproducible evidence but not continuous integration evidence. ## Behavior still to verify The path inventory cannot prove wire compatibility, and nothing in this document should be read as proving it. Before claiming alignment for an endpoint, compare against a Nexus instance and add a `compat-test` case for: - `continuationToken` paging (request parameter and response field), including invalid/foreign tokens; at the baseline only `/v1/search/assets` implements the token, and it is the only asset path compared today. Component paging does not exist yet (no list route), so it must be compared when the route is added. - Error payload shape and status codes (`400`, `401`, `403`, `404`, `409`, `422`), including validation messages. - Permission mapping: the `nexus:*` expressions listed above must gate the same operations; anonymous access rules. - Content types and upload formats (`multipart/form-data` for `/v1/components`, JSON for repository configuration). - Response headers used by clients (`Location`, `Content-Type`, `X-Siesta-Token` if still emitted by the target Nexus version). ## Deliberate non-goals - `/v1/script`: executing arbitrary Groovy is a remote-code-execution surface and is not part of the kkRepo security model. If compatibility is mandatory, gate it behind an explicit, admin-only, disabled-by-default flag. - OrientDB/Elasticsearch-specific endpoints and internal task/karaf APIs. - Azure/Google blob stores until those storage adapters exist. ## Proposed prioritization This table is a proposal for sequencing work. It is not derived from the inventory and does not assert that any listed endpoint is behaviorally compatible; the ordering weighs client/automation usage against implementation cost. | Priority | Work | Rationale | | --- | --- | --- | | P0 | `GET /v1/status`, `/v1/status/check`, `/v1/status/writable` (provided by #455), `GET /v1/search`, `/v1/search/repositories`, `DELETE /v1/components/{id}`, `DELETE /v1/repositories/{repositoryName}` | small, used by UI, probes and automation; generic DELETE is the only generic repository write Nexus has | | P1 | `GET /v1/repositorySettings`, format-specific `POST`/`PUT` repository routes, `/v1/search/assets/download`, cleanup-policy aliases, tasks read view | IaC and operations compatibility | | P2 | security tokens/SAML/LDAP/SSL/IP allowlist, blobstore CRUD, capabilities/tags/system, legacy staging/lifecycle | deeper management parity | | P3 | format-specific request schemas for every repository format, `script` (only if required) | full schema parity | The inventory must be regenerated whenever the Nexus reference version or the baseline changes; keep `scripts/nexus-rest-api-inventory.py` with the migration/compatibility tooling rather than editing the table by hand.