feat(auth): require JWT for GET /api/* endpoints with optional public demo mode#144
Open
TFT444 wants to merge 8 commits into
Open
feat(auth): require JWT for GET /api/* endpoints with optional public demo mode#144TFT444 wants to merge 8 commits into
TFT444 wants to merge 8 commits into
Conversation
Refactor public access logic and improve database migration handling.
This file contains tests for JWT authentication middleware, including both production and demo modes. It tests various endpoints for JWT requirements and public access.
Added authentication details and public demo mode information to the API reference.
Removed DATABASE_URL environment variable from rule regression tests.
H-Sihan
previously approved these changes
Jun 18, 2026
Member
|
@TFT444 , kindly fix the conflicts! Revisit the PR |
Collaborator
Author
|
@Vishnu2707 Conflict has been resolved! |
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.
What does this PR do?
Fixes a security gap where all GET requests to /api/* were publicly accessible without a JWT. Real Azure scan data including findings, compliance status, score, and resources should not be readable without authentication in production.
Type of change
Changes
api/app.py — removed
_is_public_get()which was making all/api/*GET routes public. Replaced with_ALWAYS_PUBLICset containing only/and/health. AddedOPENSHIELD_PUBLIC_DEMO=trueenv var support so deployments running a public demo dashboard can still allow unauthenticated GET requests explicitly. AddedDATABASE_URLguard so the app can start without a database during tests and local dev.tests/test_auth.py — new test file covering default mode (GET
/api/*returns 401 without JWT) and demo mode (GET/api/*allowed without JWT, POST always requires JWT,/healthalways public)..github/workflows/ci.yml — added
tests/test_auth.pyto the CI pytest command so auth coverage is enforced on every PR.docs/api-reference.md — updated auth section to reflect the new default behavior and added a reference table explaining demo mode vs production mode.
Acceptance criteria
/healthremains public in all environments/api/*GET routes return 401 without a valid JWT by defaultOPENSHIELD_PUBLIC_DEMO=trueTesting
Checklist
Related issue
Closes #141