GeezerVison is showing github.com — fix(auth): only the platform admin may create a Träger (#352) by kiodreambau · Pull Request #372 · OpenResilienceInitiative/ORISO-TenantService
Conversation
kiodreambau
commented
Nov 17, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
A Träger admin could create a whole new organisation through the API, because their role carries the same "create tenant" right as the platform admin. Creating organisations is the platform admin's job. With this change a Träger admin is refused with 403 straight away, before anything is written, so there is nothing half-created to roll back.
Closes #352
Part of OpenResilienceInitiative/ORISO-Admin#1335
What changed
TenantFacadeAuthorisationService.assertMayCreateTenants(): a caller holding CREATE_TENANT must come from the platform tenant 0 (isSuperAdmin()), otherwise AccessDeniedException → 403.
TenantServiceFacade.createTenant calls it as its very first check, before sanitising, ID allocation, the tenant insert, the consulting-type step or any rollback.
- Callers without
CREATE_TENANT (technical identity, config-wizard task identity used by the UserService onboarding) keep the existing reservation-only check. The legacy technical identity carrying tenant-admin at tenant 0 keeps its full create right, as pinned by TechnicalServiceIdentityAuthorizationIT.
- The controller
@PreAuthorize stays as is: it also admits the reservation-only identities, and the tenant claim is decided in the facade like the other platform-only guards (listing, DPA publishing).
Callers checked
- Admin UI: "create Träger" is already only offered to the super admin (
userRolesToPermissions.ts: Tenant.create: isSuperAdmin). No change needed.
- UserService public onboarding (
TenantCreationClient): uses the CONFIG_WIZARD task identity with the invite's reservation. Unaffected.
Tests (test-first: the new Träger-admin ITs were red with 200 before the fix)
TraegerAdminTenantIsolationIT (real role mapping, String tenant claim)
traegerAdmin_Should_beRefusedBeforeAnyWrite_When_creatingATraeger
-> 403, tenant count + ID ledger unchanged, no consulting-type call
traegerAdmin_Should_notConsumeAReservation_When_creatingATraegerWithItsToken
-> 403, platform-minted reservation stays RESERVED, no tenant row
platformAdmin_Should_createATraegerWithItsDefaultConsultingType
-> 200, tenant stored, createDefaultConsultingTypes(newId) called
TenantFacadeAuthorisationServiceTest: Träger admin refused, missing tenant claim refused,
platform admin passes, reservation-only callers untouched
TenantServiceFacadeTest: refusal -> no sanitise, no create, no consulting type, no rollback
TenantIdAllocationControllerIT: platformAdmin() fixture now names tenant 0 like TenantControllerIT
./mvnw -B test -> Tests run: 1308, Failures: 0, Errors: 0 (includes spotless:check)
Verified: local only (JDK 21, H2 test profile). No image built, nothing deployed.
How should I test this?
- As a Träger admin (token
tenantId = own Träger), POST /service/tenantadmin with a new organisation → 403 immediately; no new Träger appears in the platform admin's list
- As the platform admin, create a Träger in the Admin panel → it is created, including its default consulting type
- Public Träger onboarding through an invite link still creates the Träger (reservation path unchanged)
Not in this PR
The tenant-ID reservation endpoints (reserve, next free ID, availability, release) are still gated by CREATE_TENANT alone, so a Träger admin can still reserve an ID. They can no longer consume it. Tracked in #373.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Every Träger admin holds tenant-admin and with it CREATE_TENANT, so
POST /tenantadmin let them create an organisation. Since
ConsultingTypeService#190 the call failed at the consulting-type step and
was rolled back; with that step passing (as in tests), the tenant was
created and even a platform-minted ID reservation was consumed.
createTenant now refuses a CREATE_TENANT holder whose token does not name
the platform tenant 0 before anything is sanitised, allocated or written,
so there is no rollback path. Reservation-only callers (technical
identity, config-wizard task) keep the existing reservation check; the
legacy technical identity with tenant-admin at tenant 0 is unchanged.
Closes #352
Co-Authored-By: Claude Opus 5.5 <[email protected]>
coderabbitai
Bot
commented
Nov 17, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Pre-merge checks: 1
-
| Check name |
Status |
Explanation |
| Validation Evidence |
 |
Summary: The PR changes product behavior. It adds an authorization refusal to createTenant (Träger admins get 403). The check therefore applies, and it passes because the PR includes relevant automa… |
Full details: Validation Evidence
-
Explanation
Summary: The PR changes product behavior. It adds an authorization refusal to createTenant (Träger admins get 403). The check therefore applies, and it passes because the PR includes relevant automated tests and a stated validation command with its result. Evidence: - The PR description lists new tests: TraegerAdminTenantIsolationIT, TenantFacadeAuthorisationServiceTest, TenantServiceFacadeTest, and an updated TenantIdAllocationControllerIT. - The description gives the exact command (./mvnw -B test) and result (Tests run: 1308, Failures: 0, Errors: 0). It also states the environment (JDK 21, H2 test profile) and that the run was local only. - In the checked-out tree, these test files exist. TechnicalServiceIdentityAuthorizationIT also exists and covers the legacy identity path the description cites. - assertMayCreateTenants is defined in TenantFacadeAuthorisationService.java (line 115) and called from TenantServiceFacade.java (line 263). Test methods in TenantFacadeAuthorisationServiceTest.java (lines 806–844) and TenantServiceFacadeTest.java (line 877) exercise it. Gaps (not affecting the verdict): I did not run the test suite. The description says the new Träger-admin ITs failed before the fix, but I did not verify that claim. The "How should I test this" items are manual checklist items, not automated evidence. Neither gap is required by the check.
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|