This file contains rules and conventions that AI coding agents (Claude Code, Copilot, Cursor, etc.) must follow when contributing to this project.
- Build:
mvn install -DskipTests - Run all tests:
mvn integration-test - All new development targets the
masterbranch (v7)
Every REST controller endpoint that accesses study-specific data must have a @PreAuthorize annotation. Forgetting this allows unauthorized data access.
-
GET endpoints with
studyId:@PreAuthorize("hasPermission(#studyId, 'CancerStudyId', T(org.cbioportal.legacy.utils.security.AccessLevel).READ)")
-
POST fetch endpoints with filters (study collection):
@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.legacy.utils.security.AccessLevel).READ)")
These also require the
InvolvedCancerStudyExtractorInterceptor(inWebAppConfig) to handle the endpoint path.
Controllers serving only public/reference data do not need authorization. These include:
CancerTypeController— public reference dataGeneController— public reference dataGenePanelController— public reference dataGenesetController— public reference dataReferenceGenomeGeneController— public reference dataInfoController— server metadataServerStatusController— health checkCacheController/CacheStatsController— operationalIndexPageController/LoginPageController— UI pagesPublicVirtualStudiesController— explicitly public
The following controllers have known authorization gaps that are tracked as TODOs:
MutationCountController— returns aggregate mutation counts across all studies with no study IDs in the request or response;@PostFilteris not applicable; authorization approach needs further investigationMskEntityTranslationController— accesses study-specific data but lacks@PreAuthorize; currently allowed in the ArchUnit test to avoid breaking the buildGenericAssayController— accesses study-specific data;@PreAuthorizewas removed for performance reasons; currently allowed in the ArchUnit test to avoid breaking the buildColumnStoreGenericAssayController— accesses study-specific data;@PreAuthorizewas removed for performance reasons; currently allowed in the ArchUnit test to avoid breaking the buildColumnStoreStudyController— serves study data without per-study authorization; currently allowed in the ArchUnit test to avoid breaking the build
Any new exception must be documented here with a justification.
An ArchUnit test (EndpointAuthorizationArchTest) verifies that all @RequestMapping methods in @RestController classes have @PreAuthorize, unless the controller or method is in a documented exceptions list. If you add a new endpoint, the test will fail unless you either:
- Add
@PreAuthorizeto the method, OR - Add the controller to
AUTHORIZED_EXCEPTIONS(or the method toMETHOD_EXCEPTIONS) with a justification comment
- Follow existing patterns in the codebase when adding new endpoints or services
- New features should use the new persistence stack (domain/infrastructure layers), not the legacy service layer
- PRs should include test coverage for new functionality