Skip to content

CGDMF-48: Validate API scopes#9

Closed
wouterpot wants to merge 2 commits into
developfrom
CGDMF-48-Validate-API-scopes
Closed

CGDMF-48: Validate API scopes#9
wouterpot wants to merge 2 commits into
developfrom
CGDMF-48-Validate-API-scopes

Conversation

@wouterpot

Copy link
Copy Markdown
Collaborator

The different commits show a few different approaches to setting scopes for endpoints. If you're interested to see the other approaches, review by commit otherwise go straight to the aggregate view.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements API scope validation for the Documenten API by adding JWT scope checking to all protected endpoints. The implementation follows OAuth2 standards for scope claims and includes wildcard scope matching for administrative convenience.

Changes:

  • Introduces a new checkScope function that validates JWT scopes against required permissions for each endpoint
  • Adds scope checks to all CRUD operations across EnkelvoudigInformatieObjecten, ObjectInformatieObjecten, and AuditTrail routes using Dutch scope names (e.g., "documenten.lezen", "documenten.aanmaken")
  • Implements comprehensive test coverage for the scope checking mechanism, including wildcard matching and multiple scope validation

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main/kotlin/api/routes/CheckScope.kt New scope authorization implementation with JWT claim extraction, wildcard matching, and custom exception handling
src/test/kotlin/api/middleware/CheckScopeTest.kt Comprehensive test suite covering various scope validation scenarios including multiple scopes, wildcards, and array-style scopes
src/main/kotlin/api/routes/EnkelvoudigInformatieObjectenRoutes.kt Adds scope checks to all document CRUD operations (list, create, get, put, patch, delete, download, lock, unlock) and cleans up import ordering
src/main/kotlin/api/routes/ObjectInformatieObjectenRoutes.kt Adds scope checks to object relation operations (list, create, get, delete)
src/main/kotlin/api/routes/AuditTrailRoutes.kt Adds scope checks to audit trail endpoints and refactors to use RequestScopeKey pattern for service retrieval
src/main/kotlin/api/middleware/GlobalExceptionHandler.kt Adds ScopeAuthorizationException handler that returns proper 403 Forbidden responses with detailed error messages
src/main/kotlin/api/DocumentenApiRoutes.kt Minor import consolidation cleanup

Comment thread src/main/kotlin/api/routes/CheckScope.kt Outdated
Comment thread src/test/kotlin/api/middleware/CheckScopeTest.kt Outdated
Comment thread src/main/kotlin/api/routes/EnkelvoudigInformatieObjectenRoutes.kt
Comment thread src/main/kotlin/api/routes/ObjectInformatieObjectenRoutes.kt
@wouterpot wouterpot force-pushed the CGDMF-48-Validate-API-scopes branch 4 times, most recently from 3bbc792 to e770f02 Compare March 2, 2026 14:48
@wouterpot wouterpot force-pushed the CGDMF-48-Validate-API-scopes branch 2 times, most recently from 4e097a2 to ec64e7a Compare March 12, 2026 16:18
@wouterpot wouterpot force-pushed the CGDMF-48-Validate-API-scopes branch from ec64e7a to 53b93d5 Compare March 24, 2026 10:26
@wouterpot wouterpot force-pushed the CGDMF-48-Validate-API-scopes branch from 53b93d5 to 980c5fd Compare March 27, 2026 14:06
@wouterpot wouterpot force-pushed the CGDMF-48-Validate-API-scopes branch 3 times, most recently from fad4856 to 478ae46 Compare April 21, 2026 14:51
github-actions Bot added a commit that referenced this pull request Apr 26, 2026
@wouterpot wouterpot force-pushed the CGDMF-48-Validate-API-scopes branch 4 times, most recently from ae3d57c to c8765ec Compare May 7, 2026 15:48
@wouterpot wouterpot force-pushed the CGDMF-48-Validate-API-scopes branch from c8765ec to bc830b7 Compare May 7, 2026 16:25
@wouterpot wouterpot force-pushed the develop branch 3 times, most recently from 70182e3 to f648d70 Compare June 5, 2026 11:57
@wouterpot wouterpot closed this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants