feat: management REST API for projects, profiles, forward nodes, auth configs, and monitoring - #297
Open
jbardet wants to merge 3 commits into
Open
feat: management REST API for projects, profiles, forward nodes, auth configs, and monitoring#297jbardet wants to merge 3 commits into
jbardet wants to merge 3 commits into
Conversation
… configs, and monitoring Adds a programmatic configuration surface alongside the Vaadin UI: ProjectController, ProfileController, ForwardNodeController, AuthConfigController, MonitoringController. Auth reuses the existing Spring Security setup (HTTP Basic added to the in-memory IdP chain alongside the existing form login; OIDC unchanged). Also fixes a pre-existing bug surfaced while adding project deletion via the API: ProjectService.remove() left dangling FKs on destinations that referenced the deleted project (de-identification or tag morphing), which would violate the database constraint on delete. Monitoring endpoints are adapted to the current aggregated per-series model (TransferSeriesStatusEntity) via the specification-based pagination/count TransferSeriesStatusRepo already provides. Ported from jbardet/karnak (1.1.1-based fork) onto current master.
API.md documents every endpoint added in the previous commit (updated for the current aggregated per-series monitoring model: status values ALL/SENT/NOT_SENT/EXCLUDED/ERROR, no sopInstanceUid/quoteCharacter). karnak-api-client (python-client/) and setup_deid_gateway.py are an optional companion, not core: a thin authenticated HTTP client plus an idempotent desired-state apply_config() from a JSON document. Kept as a separate commit so it can be split into its own PR if preferred. Ported from jbardet/karnak (1.1.1-based fork) onto current master.
Found by driving the ported REST API through a real downstream pipeline
before opening the upstream PR:
- /api/** had no explicit authorization rule, so authenticated requests
fell through to VaadinSecurityConfigurer's route-based access control,
which denies (403) any route it doesn't recognize as a Vaadin view.
Add an explicit requestMatchers("/api/**").authenticated() rule in
both SecurityInMemoryConfig and SecurityConfiguration (OIDC).
- Spring Security's default CSRF protection rejected every POST/PUT/
DELETE to /api/** from non-browser Basic-auth clients (no CSRF token
available), making the API's actual write operations unusable for its
intended scripted/automated callers. Exempt /api/** from CSRF, the
conventional treatment for a stateless REST API.
- ArgumentEntity.profileElementEntity, TagEntity.profileElementEntity,
ProfileEntity.projectEntities, and KheopsAlbumsEntity.destinationEntity
are bidirectional JPA back-references that were missing @JsonIgnore.
Since the forward side of each relationship is already reachable from
a REST response (profile elements, tags/arguments, project<->profile,
destination<->kheopsAlbums), Jackson recursed through the cycle
indefinitely, producing truncated/invalid JSON on GET /api/projects
and GET /api/forward-nodes instead of a 200 response.
Verified live against the ported build: GET now returns 200/204 instead
of 403, POST returns normal validation responses instead of 403, and
GET /api/projects returns clean, complete JSON instead of a truncated
multi-hundred-level-deep recursive body.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What's in this PR
Five controllers under org.karnak.backend.controller: ProjectController, ProfileController, ForwardNodeController, MonitoringController, AuthConfigController, plus API.md as the endpoint reference. Auth reuses the existing Spring Security setup as-is, no new auth mechanism.
Adapting this onto current master needed real changes beyond a straight port:
Bugs found and fixed via live end-to-end testing
Since this PR touches the security chain, I didn't want to ship it validated only by MockMvcBuilders.standaloneSetup() (which never exercises the real filter chain), so I ran it against a real downstream pipeline as an actual scripted client would use it: auth, config apply, then driving DICOM through a shift_from_api-configured profile. That surfaced three real bugs, all fixed in this branch:
Testing
Built and tested in a maven:3.9-eclipse-temurin-25 container against current master:
Scope
Kept the Python client (python-client/) and setup_deid_gateway.py as a separate second commit on the same branch (all of its own tests pass), so it can be split into its own PR later if you'd prefer Java-only first.