Skip to content

Add EnvVarHeaderContentGuard - #8015

Merged
ggainey merged 1 commit into
pulp:mainfrom
decko:pulp-2257-envvar-header-guard
Sep 22, 2026
Merged

ggainey merged 1 commit into
pulp:mainfrom
decko:pulp-2257-envvar-header-guard

Conversation

@decko

@decko decko commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds EnvVarHeaderContentGuard so a Base64-encoded request header can be checked against a content-app environment variable (fixes #8007). Rotation is a deploy/env change, not a DB update of HeaderContentGuard.header_value.
  • env_var must be listed in ENVVAR_HEADER_CONTENT_GUARD_ALLOWED_VARS (default []). The secret is never stored or returned by the API.
  • Unit and functional tests use ENVVAR_HEADER_GUARD_TEST_SECRET from the Pulp container env (injected via template_config.yml / CI pulp_env).

Test plan

  • pytest -k envvar_header unit tests (secret + allowlist set in the pulp container)
  • pytest -k envvar_header functional tests (create guard, 403 without/wrong header, 404 with matching Base64 header, 400 for disallowed env_var, access policy present)
  • Confirm OpenAPI path /pulp/api/v3/contentguards/core/envvar_header/ and that GET does not expose a secret value

Related: PULP-2257, pulp-service prototype pulp/pulp-service#1420

Closes #8007

Assisted-by: Cursor Grok 4.6

Made with Cursor

component_version: "${COMPONENT_VERSION}"
pulp_env: {"PULP_CA_BUNDLE": "/etc/pulp/certs/pulp_webserver.crt"}
pulp_settings: {"allowed_export_paths": ["/tmp"], "allowed_import_paths": ["/tmp"], "api_root": "/pulp/", "content_path_prefix": "/somewhere/else/", "csrf_trusted_origins": ["https://pulp:443"], "distributed_publication_retention_period": 3, "orphan_protection_time": 0, "task_diagnostics": ["memory"], "task_protection_time": 10, "tmpfile_protection_time": 10, "upload_protection_time": 10}
pulp_env: {"ENVVAR_HEADER_GUARD_TEST_SECRET": "functional-test-secret-value", "PULP_CA_BUNDLE": "/etc/pulp/certs/pulp_webserver.crt"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the next plugin-template run will throw this away. Also - static secrets, even test ones, make gitleaks yell at us. Let's generate a random one "on the fly", something like this:

https://github.com/pulp/pulp-cli/pull/1447/changes#diff-91c0a0e51396a0be3f344ba35b45cc37d0f992032ff5b04938f2a8c296115931R72

Once we like it here, let's get this into plugin_template instead.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread docs/user/guides/protect-content.md Outdated
Comment thread pulpcore/app/models/publication.py Outdated
Comment thread pulpcore/app/models/publication.py
Comment thread pulpcore/app/models/publication.py Outdated
Comment thread pulpcore/app/settings.py
Comment thread template_config.yml Outdated
@decko
decko force-pushed the pulp-2257-envvar-header-guard branch from 807bd9e to 14d2a08 Compare September 22, 2026 11:46
@decko
decko force-pushed the pulp-2257-envvar-header-guard branch 2 times, most recently from 14ebdef to 6ae3d7a Compare September 22, 2026 12:12
Validate a Base64-encoded request header against a content-app environment variable so shared secrets can rotate without updating guard records. Names must be listed in ENVVAR_HEADER_CONTENT_GUARD_ALLOWED_VARS.

fixes pulp#8007

Assisted-by: Cursor Grok 4.6
@decko
decko force-pushed the pulp-2257-envvar-header-guard branch from 6ae3d7a to ce811ce Compare September 22, 2026 12:15
Comment thread pulpcore/app/models/publication.py
Comment thread .github/workflows/scripts/before_install.sh
@ggainey
ggainey merged commit c9e8416 into pulp:main Sep 22, 2026
13 of 14 checks passed
@decko
decko deleted the pulp-2257-envvar-header-guard branch September 22, 2026 20:00
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.

Add EnvVarHeaderContentGuard for env-backed header secret validation

2 participants