fix: require authentication on user-balance stats endpoint#241
Open
Dextheking1 wants to merge 580 commits into
Open
fix: require authentication on user-balance stats endpoint#241Dextheking1 wants to merge 580 commits into
Dextheking1 wants to merge 580 commits into
Conversation
fix: the income and expand static which was displayed on the homepage is for 7 days.
feat: add a upright arrow icon to the new-paged link
fix: copy button on home does not work
feat: 杂项动画修正
fix: dispute error
feat: utilizing the service layer mechanism, a rate layer is establis…
fix: redenvelope api limit error
fix: rate release for API interception
This reverts commit e5ffac6.
refactor(middlewares): enhance logging format in LoginRequired middle…
feat(risk): add risk block dialog and related components
fix(risk-warning-toast): enable close button and dismissible option
feat(risk): add risk items to risk response and update headers
refactor(oauth): centralize audit logging with `LogForAudit` function
fix(payment): preserve disputed quota and add csrf guard
feat(table-data): link app names to their homepage if URL is available
feat: implement probe services for scheduler and worker
fix(oauth): release conflicted username without disabling account
feat(admin): add order management and refund support
The /api/v1/dashboard/stats/user-balance route was registered directly on apiV1Router, outside the dashboardRouter group that applies oauth.LoginRequired(). Its two sibling dashboard stats routes (/stats/daily, /stats/top-customers) are gated, but this one was reachable unauthenticated, exposing aggregate balance statistics (total user count, sum/avg/median/min/max/stddev of all balances). Move the route into the dashboardRouter group so it inherits the same authentication middleware. The route path is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
The
/api/v1/dashboard/stats/user-balanceroute is registered directly onapiV1Router(internal/router/router.go:156), outside thedashboardRoutergroup that appliesoauth.LoginRequired().Its two sibling dashboard-stats routes are gated:
As a result this endpoint is reachable unauthenticated and returns aggregate balance statistics over all users (total user count, and sum/avg/median/min/max/stddev of
available_balance).Fix
Move the route into the
dashboardRoutergroup so it inheritsoauth.LoginRequired(). The route path is unchanged (/api/v1/dashboard/stats/user-balance); only the middleware chain changes.Impact
Low: the data is aggregate only (no per-user PII), but it discloses the size and distribution of the credit economy to anonymous callers, and it is inconsistent with the other dashboard routes.
Testing
gofmtparses cleanly. I could not run a fullgo buildlocally (the module requires Go 1.26; I have 1.22 available), but the change is a one-line relocation of an existing route registration into a sibling group already in scope.