Repository navigation
feat(backend): [DEMO] add v2 group endpoints - #7549
Draft
maverbiest wants to merge 3 commits into
Draft
maverbiest wants to merge 3 commits into
maverbiest wants to merge 3 commits into
Conversation
Add the v2 module with its own security chain for /v2/**, per-endpoint access annotations (documented in the OpenAPI spec as x-access) and the group endpoints. The groups code moves from v1 to core so that v1 and v2 share one implementation. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
Note
Demo, stacked on #7540. It shows what adding a v2 endpoint looks like once the backend is split into modules. #7539 adds the same endpoints as a separate service; the comparison is below.
What this does
v2module, served under/v2. It depends only oncore, never onv1.v1tocore, so v1 and v2 share one implementation. v2 groups is just a new controller over the existing service.The diff
core: tables, types and the permission checks are pure renames. Changes toGroupManagementDatabaseService:getGroupandgetMembersmethods, with v1'sgetDetailsOfGroupbuilt from themGroupEntity/UserGroupEntityDAO classes are removed, and v1's released-data stream joins the groups table instead of looking up each row's group name through themPSQLState.UNIQUE_VIOLATIONinstead of a constant from v1'sSubmitModelcore: v1's bearer-token setup (token validation and the logging of rejected requests) is now one shared function incore, used by both v1's and v2's security chains. That is the only change to v1's code.config/V2Config.kt: the/v2/**security chaincontroller/GroupController.kt: the group endpointscoreandv2only, without v1. The shared group test constants move to core's test fixtures.v2 group endpoints
GET /v2/groups?name=GET /groups?name=POST /v2/groups→201+LocationPOST /groups→200GET /v2/groups/{groupId}GET /groups/{groupId}(.group)PUT /v2/groups/{groupId}PUT /groups/{groupId}GET /v2/groups/{groupId}/membersGET /groups/{groupId}(.users)PUT /v2/groups/{groupId}/members/{username}PUT /groups/{groupId}/users/{username}DELETE /v2/groups/{groupId}/members/{username}DELETE /groups/{groupId}/users/{username}GET /v2/me/groupsGET /user/groupsAccess control in v2
/v2/**, ordered before v1's catch-all chain. Every v2 endpoint requires a token, except the public ones the chain lists (currently onlyGET /v2/groups/{groupId}).@SecurityRequirements(a standard Swagger annotation), so the API docs say they need no token (Document authorization more explicitly to make it easier to test correct behavior and avoid issues #1614). In v1, the docs claim every endpoint needs a token.PublicEndpointsTestpins which endpoints the docs call public, then sends a request without a token to every v2 endpoint to check that the security chain agrees. Making an endpoint public therefore always shows up in review, and the docs can't silently disagree with the security chain.Compared with #7539
corecore(#7540)Things to discuss
corechanges v1 as well.hasAuthority(...)rules in the security chain as v1 does, or Spring's@PreAuthorizeon the method.Testing
./gradlew test: all 672 tests pass. That's the 661 existing tests plus 11 new ones: 8 for the group endpoints, 1 public-endpoints test and 2 app-level tests../gradlew ktlintCheckis clean.PublicEndpointsTestcatches mismatches in both directions: it fails both when the docs annotation is removed from the public endpoint, and when the security chain makes another endpoint public.GET /v2/groups/1→ 404 (public, the group doesn't exist),GET /v2/groups→ 401,POST /v2/groups→ 403,POST /groups(v1) → 403/api-docslists 29 v1 and 5 v2 paths, withsecurity: []only onGET /v2/groups/{groupId}🤖 Generated with Claude Code
🚀 Preview: Add
previewlabel to enable