Skip to content

Enforce EnablePublicGraphs and DisableGraphsForBlueTeam in graph handlers - #210

Open
tire-fire wants to merge 2 commits into
dbaseqp:mainfrom
tire-fire:fix/enforce-graph-flags
Open

tire-fire wants to merge 2 commits into
dbaseqp:mainfrom
tire-fire:fix/enforce-graph-flags

Conversation

@tire-fire

Copy link
Copy Markdown
Contributor

Summary

EnablePublicGraphs and DisableGraphsForBlueTeam existed in the config but neither was checked by the graph API handlers; the three graph endpoints (/api/graphs/services, /api/graphs/scores, /api/graphs/uptimes) were always publicly accessible regardless of their values.

A new checkGraphAccess helper, called before CheckCompetitionStarted in all three handlers, enforces both flags:

  • EnablePublicGraphs = false: anonymous callers (no session) get 403 Forbidden.
  • DisableGraphsForBlueTeam = true: callers with the team role but not admin get 403 Forbidden.

Admins always pass. The graph page (/graphs) already shows a countdown before the competition starts and is unaffected; this change is to the API endpoints only.

Verification

TestGraphsPublicDisabled, TestGraphsBlueTeamDisabled, TestGraphsAdminAlwaysPasses cover the three handlers for each scenario. Without the flag checks, anonymous callers reach the nil DB and panic rather than getting 403.

go test -short ./www/api/ -run TestGraphs passes.

@tire-fire
tire-fire force-pushed the fix/enforce-graph-flags branch from fd046b1 to 80ad8ca Compare November 13, 2026 05:37
…lers

Both flags existed in config but neither was checked by the handlers;
the graph APIs were always publicly accessible. Anonymous callers are
now refused when EnablePublicGraphs is off; team-role callers when
DisableGraphsForBlueTeam is on. Admins always pass.
@tire-fire
tire-fire force-pushed the fix/enforce-graph-flags branch from 80ad8ca to 1e276f7 Compare November 13, 2026 05:45
- gofmt alignment fix in graphs_test.go
- Remove two tautological assert.NotEqual(StatusForbidden) lines that
  were implied by the preceding assert.True(checkGraphAccess) result
- GraphPage now gates on EnablePublicGraphs (redirects anon to /login)
  and DisableGraphsForBlueTeam (403 for team-role callers), mirroring
  the checkGraphAccess guard already applied to the three API endpoints
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.

1 participant