Skip to content

CGDMF-48: Validate API scopes#9

Open
wouterpot wants to merge 1 commit intodevelopfrom
CGDMF-48-Validate-API-scopes
Open

CGDMF-48: Validate API scopes#9
wouterpot wants to merge 1 commit intodevelopfrom
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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 from 980c5fd to 65dc3bd Compare April 16, 2026 13:55
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