# Reaver dashboard web root — baseline hardening (Apache 2.4+)

Options -Indexes

# Sensitive trees use their own Require all denied (.htaccess).
# install/ holds nginx templates — not for public download.
<IfModule mod_authz_core.c>
    RedirectMatch 404 (?i)^/install/
</IfModule>

# Security headers (PHP also sends these; Apache is a belt-and-suspenders layer)
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
    Header set Permissions-Policy "camera=(), microphone=(), geolocation=()"
    # COOP is set in PHP (shared/config.php). Do not force same-origin here —
    # /oauth/authorize must keep the MCP client's popup attached to its opener.
</IfModule>

# Prefer reaver.php as directory index
DirectoryIndex reaver.php index.php

# /api/v1/* → front controller (including openapi.json — never serve it statically).
# Also copy Authorization into the CGI environment (PHP-FPM/CGI often drop it).
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteRule ^\.well-known/oauth-protected-resource(/.*)?$ api/v1/index.php [QSA,L]
    RewriteRule ^\.well-known/oauth-authorization-server(/.*)?$ api/v1/index.php [QSA,L]
    RewriteRule ^\.well-known/openid-configuration$ api/v1/index.php [QSA,L]
    RewriteRule ^api/v1/index\.php$ - [L]
    RewriteRule ^api/v1(/.*)?$ api/v1/index.php [QSA,L]
</IfModule>

# Block common junk probes
<IfModule mod_authz_core.c>
    <FilesMatch "(?i)^(\.env|\.git|composer\.(json|lock)|.*\.(sql|sqlite|bak|old))$">
        Require all denied
    </FilesMatch>
</IfModule>
