Skip to content

Conversation

@tvandort
Copy link
Contributor

@tvandort tvandort commented Jan 15, 2026

Ticket ENG-2404

Description Of Changes

Updates CSP header definitions to include docs pages. These were broken when FIDES__SECURITY__HEADER_MODE was set to recommended.

The changes include domains for scripts, styles, and images that are required for the respective page to load.

Code Changes

  • Added CSP definition for Swagger on /docs
  • Added CSP definition for Redoc on /redoc

Steps to Confirm

  1. Set FIDES__SECURITY__HEADER_MODE=recommended
  2. Start Fides API
  3. Browse to /docs make sure the page loads and the console doesn't log any CSP errors
  4. Browse to /redoc make sure the page loads and the console doesn't log any CSP errors

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@tvandort tvandort requested a review from a team as a code owner January 15, 2026 23:12
@tvandort tvandort requested review from galvana and removed request for a team January 15, 2026 23:12
@vercel
Copy link
Contributor

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Jan 16, 2026 3:47pm
fides-privacy-center Ignored Ignored Jan 16, 2026 3:47pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 15, 2026

Greptile Summary

This PR adds Content Security Policy (CSP) headers for the /docs (Swagger) and /redoc API documentation endpoints to fix broken pages when FIDES__SECURITY__HEADER_MODE is set to recommended.

Changes include:

  • Added domain constants for external CDNs (cdn.jsdelivr.net, fastapi.tiangolo.com, cdn.redoc.ly, Google Fonts domains)
  • Created two new CSP header configurations: recommended_csp_header_value_for_swagger and recommended_csp_header_value_for_redoc
  • Updated the negative lookahead regex pattern to exclude /docs and /redoc from the default CSP policy
  • Added two new HeaderRule entries for the /docs and /redoc endpoints with their specific CSP configurations
  • Added comprehensive test coverage for both new endpoints

The implementation correctly whitelists the necessary external resources (scripts, styles, fonts, images) required for each documentation page to render properly while maintaining security through CSP.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward and well-tested, adding CSP headers for documentation endpoints. The implementation follows existing patterns, includes comprehensive test coverage, and only affects security headers for two specific endpoints. No logic changes to core functionality.
  • No files require special attention

Important Files Changed

Filename Overview
changelog/7235-add-docs-csp-headers.yaml Changelog entry properly formatted with correct type, description, and PR number
src/fides/api/util/security_headers.py Added CSP configurations for /docs and /redoc endpoints with appropriate domain whitelisting for Swagger and Redoc dependencies
tests/api/util/test_security_headers.py Comprehensive test coverage added for new /docs and /redoc security headers

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@tvandort
Copy link
Contributor Author

@gretile pls rereview

@tvandort
Copy link
Contributor Author

@greptile pls rereview

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.

2 participants