Open
Conversation
Contributor
There was a problem hiding this comment.
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
checkScopefunction 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 |
3bbc792 to
e770f02
Compare
4e097a2 to
ec64e7a
Compare
ec64e7a to
53b93d5
Compare
53b93d5 to
980c5fd
Compare
980c5fd to
65dc3bd
Compare
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.
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.