Repository navigation
feat: support disabling directory listing in the httpd oidc image - #56
Merged
Merged
Conversation
The <Directory> block guarding the document root hardcodes
Options SymLinksIfOwnerMatch Indexes in all five vhost blocks across the
three site templates, and AllowOverride None blocks any .htaccess override,
so there was no way to turn mod_autoindex off. Combined with
HTTPD_SITE_DIRECTORY_INDEX defaulting to "disabled" when unset, an otherwise
unconfigured container answers a directory request with a full listing of its
document root -- for the gcsfuse use case, the entire object namespace of the
mounted bucket.
Add HTTPD_SITE_DIRECTORY_LISTING_ENABLED and derive the rendered Options list
from it, substituting ${HTTPD_SITE_DIRECTORY_OPTIONS} into the templates the
same way ${HTTPD_SITE_DIRECTORY_INDEX} already is. The uncomment_config_element
idiom used for ServerName and OIDCRemoteUserClaim does not fit, because the two
variants are the same directive with different arguments rather than a directive
that is present or absent, and appending a second Options directive is not an
option either: Apache rejects a context that mixes the bare and +/- forms.
The toggle is opt-out -- only an explicit false or 0 drops Indexes -- so
existing deployments are unaffected by the upgrade and nothing that relies on
listings loses them silently.
HTTPD_SITE_DIRECTORY_OPTIONS also gets a Dockerfile ENV default, because an
undefined config variable inside an Options directive is a hard parse error
(Illegal option ${...}) rather than the warning DirectoryIndex produces for the
same situation, and the config should still parse when Apache is invoked without
the entrypoint having run.
Verified against the published 0.4.1 image with these files overlaid, serving a
root containing index.html, somefile.txt and subdir/nested.txt with no index in
subdir. Stock 0.4.1 and the unset-overlay both return a listing for / and
/subdir/, so the upgrade is a no-op by default. Setting the variable to 0 or to
false returns 403 for both while /subdir/nested.txt still returns 200, so
enumeration is suppressed without affecting retrieval by name. Setting it to 0
alongside HTTPD_SITE_DIRECTORY_INDEX=index.html serves the index at / and 403s
/subdir/. apache2ctl configtest reports Syntax OK for all three site templates
under both rendered Options values.
Fixes #55
Signed-off-by: Nathan Klick <nathan@swirldslabs.com>
nathanklick
force-pushed
the
feat/httpd-oidc-directory-listing-toggle
branch
from
September 21, 2026 19:56
c417512 to
217b3e0
Compare
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.
Fixes #55.
What this changes
The
<Directory>block guarding the document root hardcodesOptions SymLinksIfOwnerMatch Indexesin all five vhost blocks across the three site templates, andAllowOverride Noneblocks any.htaccessoverride, so there is currently no way to turnmod_autoindexoff. Combined withHTTPD_SITE_DIRECTORY_INDEXdefaulting todisabledwhen unset, an otherwise unconfigured container answers a directory request with a full listing of its document root — for the gcsfuse use case, the entire object namespace of the mounted bucket.This adds
HTTPD_SITE_DIRECTORY_LISTING_ENABLEDand derives the renderedOptionslist from it:HTTPD_SITE_DIRECTORY_LISTING_ENABLEDOptionsSymLinksIfOwnerMatch Indexes0orfalseSymLinksIfOwnerMatchThe templates now substitute
${HTTPD_SITE_DIRECTORY_OPTIONS}the same way they already substitute${HTTPD_SITE_DIRECTORY_INDEX}. That variable is an implementation detail derived inconfigure_virtual_hostsand always overwritten there; the boolean is the supported knob.Why not the existing idioms
uncomment_config_element(as used forServerName,OIDCRemoteUserClaim,OIDCXForwardedHeaders) does not fit. Those are directives that are either present or absent. Here the two variants are the same directive with different arguments, so uncommenting would leave twoOptionslines in one block.Options -Indexesdirective is not viable either. Apache rejects a context that mixes the bare and+/-forms, so it would force the existing directive to be rewritten in+/-form throughout, changing its merge semantics.Backward compatibility
The toggle is opt-out — only an explicit
falseor0dropsIndexes. Leaving the variable unset renders exactly what this image renders today, so the upgrade is a no-op for existing deployments and nothing that relies on listings loses them silently.HTTPD_SITE_DIRECTORY_OPTIONSalso gets a DockerfileENVdefault. An undefined config variable inside anOptionsdirective is a hard parse error (Illegal option ${...}) rather than the warningDirectoryIndexproduces for the same situation, so the default keeps the config parsable when Apache is invoked without the entrypoint having run —apache2ctl configtestoverdocker exec, for instance.Verification
Against the published
0.4.1image with these files overlaid, serving a document root containingindex.html,somefile.txtandsubdir/nested.txt(no index insubdir/):GET /GET /subdir/GET /subdir/nested.txt0.4.1, no overlay=0=false=0+HTTPD_SITE_DIRECTORY_INDEX=index.htmlindex.htmlStock and unset-overlay are identical. Disabling the listing suppresses enumeration without affecting retrieval of files by name, and
mod_autoindexlogs the suppression explicitly (AH01276: ... server-generated directory index forbidden by Options directive).apache2ctl configtestreportsSyntax OKfordefault-nossl,default-sslanddefault-ssl-redirectunder both renderedOptionsvalues.shellcheckonentrypoint-helper.shreports nothing beyond the pre-existingSC1091for thelogger.shsource.Follow-up
Once this ships,
applications/apache-httpd-oidcinrelease-engineering-infrastructureneeds a matchinghttpd.site.directoryListingvalue and anappVersionbump. The sites it serves (jrs-reports,perf-analytics,cross-ledger-files) all currently run with the chart defaultdirectoryIndex: "disabled", which is precisely the combination that produces a browsable listing.