CLIENT IP / SPOOFABILITY. docs/geenforce-api-cutover.md claimed that removing the IIS rewrite rule made the allowlist fail closed and that it does NOT become spoofable. The opposite is true. IIS never sets X-Forwarded-For on its own; the rule is the only thing that does. Remove it and IIS still forwards whatever X-Forwarded-For the CALLER sent, waitress trusts it because it arrives from 127.0.0.1, and remote_addr becomes attacker-controlled - so a token-less caller can fetch manifests from anywhere on the network. The document and the _trusted_client_ip docstring now say so, waitress runs with --trusted-proxy-count=1, and stage 5 checks the rule is actually live rather than assuming it. The wizard question is rephrased to something an operator can verify with their network team instead of guessing at. NON-ASCII. The style gate only ever checked .py/.vue/.js/.ts, so documentation accumulated em-dashes, arrows and box-drawing characters against this repo's own convention - including in files added this week. Cleaned, and the gate now uses INCLUDES_ALL so Markdown, JSON and YAML are covered. PLUGIN DEFAULTS. The wizard pre-ticked measuringtools and printedparts, both of which ship default_enabled=false, so every site taking the defaults installed and enabled them against their manifests. Inno has no JSON parser so the list must be hardcoded, but tests/test_installer_defaults.py now fails when it drifts. UPGRADES. The payload copy merges, so a plugin dropped from a site's profile kept its code forever - which defeats a lean build and leaves core's optional-import guards succeeding for a plugin the site no longer has. Stale plugin directories are now deregistered and removed before the copy. add-plugin used 'plugin install', which for the five default_enabled=false plugins left them installed but DISABLED - and printed a green success line anyway. It now goes through apply-profile, and the success line is gated on the exit code. Invoke-Flask records its own exit status, because $LASTEXITCODE keeps a stale value when flask.exe is missing and no native command runs. CHARSET. The utf8mb4 compiler hook lived inline in migrations/env.py, so it covered the CORE chain only: plugin baselines inherited the server default, which on a latin1 server means two charsets in one database. It is now shopdb/utils/mysql_charset.py, imported by both, and preflight reports the database's default charset. BACKUP HONESTY. The dump was described as 'all of your asset data'. Uploaded branding and floor-map images live in instance\ on disk, not in the database, so a restore from the .sql alone comes back with no map. backup now archives instance\ alongside it and says both are needed. VERSIONING. AppVersion was hardcoded at 0.9.0 while the product, the frontend and the newest tag said 0.7.0 - and 0.9.0 collides with a retired contract version. Both builders now generate version.iss from shopdb/__init__.py. Smaller: rollback overwrites .env before deleting it, as uninstall already did; appcmd unlocks are scoped to this site's location rather than server-wide, with the wide unlock as a fallback; DEVELOPMENT-SETUP says Python 3.14; the README plugin list gains printedparts; prune-schema --force is documented as first-provisioning-only; HTTPS is documented as not-the-default with the steps to add it; the DBA SQL is on the wizard's database page; the features page says unticking does not remove an installed feature; and the installer README states that bundle-lock cannot vouch for the exe itself - that needs signing or an out-of-band hash, neither of which is wired up.
128 lines
5.7 KiB
XML
128 lines
5.7 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
IIS site config for shopdb-flask via HttpPlatformHandler.
|
|
|
|
IIS launches waitress (a Windows-friendly WSGI server; gunicorn does NOT run
|
|
on Windows) and forwards requests to it on a private loopback port that IIS
|
|
assigns via %HTTP_PLATFORM_PORT%. One process serves both /api and the built
|
|
Vue SPA (frontend/dist), so no separate static site is needed.
|
|
|
|
Prerequisites on the box:
|
|
- HttpPlatformHandler IIS module installed
|
|
(https://www.iis.net/downloads/microsoft/httpplatformhandler)
|
|
- URL Rewrite module installed (only for the optional X-Forwarded-For rule)
|
|
- Python 3.14 + a venv at APP_ROOT\venv with requirements.txt + waitress
|
|
- Secrets live in APP_ROOT\.env (wsgi.py load_dotenv() reads it). Keep them
|
|
OUT of this file. Lock .env ACLs to the app pool identity + admins.
|
|
|
|
Replace APP_ROOT (C:\shopdb-flask below) with the real deploy path. The IIS
|
|
site's physical path MUST be APP_ROOT (where wsgi.py lives).
|
|
-->
|
|
<configuration>
|
|
<system.webServer>
|
|
|
|
<handlers>
|
|
<add name="httpplatformhandler" path="*" verb="*"
|
|
modules="httpPlatformHandler" resourceType="Unspecified" />
|
|
</handlers>
|
|
|
|
<httpPlatform
|
|
processPath="C:\shopdb-flask\venv\Scripts\waitress-serve.exe"
|
|
arguments="--port=%HTTP_PLATFORM_PORT% --host=127.0.0.1 --threads=8 --trusted-proxy=127.0.0.1 --trusted-proxy-headers=x-forwarded-for --trusted-proxy-count=1 wsgi:app"
|
|
stdoutLogEnabled="true"
|
|
stdoutLogFile="C:\shopdb-flask\logs\httpplatform"
|
|
startupTimeLimit="120"
|
|
startupRetryCount="3">
|
|
<environmentVariables>
|
|
<!-- FLASK_ENV MUST be production here or wsgi.py defaults to the dev
|
|
config (SQL echo, debug, wrong DB URL). Real secrets go in .env. -->
|
|
<environmentVariable name="FLASK_ENV" value="production" />
|
|
<environmentVariable name="PYTHONPATH" value="C:\shopdb-flask" />
|
|
<!-- Subpath method only: when this web.config sits in an IIS
|
|
Application (e.g. /ops) under an existing site instead of its own
|
|
site, tell the app its mount path. Must match the alias the
|
|
Application was created with AND the VITE_BASE_PATH the frontend
|
|
was built with ('/ops/'). Omit for the own-site method.
|
|
<environmentVariable name="MOUNT_PATH" value="/ops" />
|
|
-->
|
|
</environmentVariables>
|
|
</httpPlatform>
|
|
|
|
<!--
|
|
Forward the real client IP, so the audit log, the kiosk visitor-location
|
|
feature (IP -> business unit), the GE-Enforce IP allowlist and per-host
|
|
login rate limiting all see the caller rather than the loopback address
|
|
HttpPlatformHandler connects from.
|
|
|
|
IIS does not set X-Forwarded-For on its own. Without the rule below there
|
|
is no such header at all, and every client looks like 127.0.0.1 - so the
|
|
allowlist and the visitor-location lookup silently stop working.
|
|
|
|
ONLY CORRECT WHEN IIS IS DIRECTLY EXPOSED. It overwrites the header with
|
|
REMOTE_ADDR, which is what stops a client spoofing its own X-Forwarded-For.
|
|
Behind a reverse proxy (ARR, a load balancer) REMOTE_ADDR is the PROXY, so
|
|
this rule would destroy the real client IP - there, leave it disabled and
|
|
let the proxy set the header.
|
|
|
|
It ships DISABLED because it needs the URL Rewrite module; enabled without
|
|
it, IIS returns HTTP 500.19 ("configuration section not well-formed").
|
|
|
|
The installer handles both: -ClientIpSource direct installs URL Rewrite
|
|
from the bundle and enables this; -ClientIpSource proxy leaves it alone.
|
|
By hand: install URL Rewrite, then delete the two marker lines below.
|
|
-->
|
|
<!-- SHOPDB-CLIENTIP-BEGIN
|
|
<rewrite>
|
|
<allowedServerVariables>
|
|
<add name="HTTP_X_FORWARDED_FOR" />
|
|
</allowedServerVariables>
|
|
<rules>
|
|
<rule name="Set X-Forwarded-For" stopProcessing="false">
|
|
<match url=".*" />
|
|
<serverVariables>
|
|
<set name="HTTP_X_FORWARDED_FOR" value="{REMOTE_ADDR}" />
|
|
</serverVariables>
|
|
<action type="None" />
|
|
</rule>
|
|
</rules>
|
|
</rewrite>
|
|
SHOPDB-CLIENTIP-END -->
|
|
|
|
</system.webServer>
|
|
|
|
<!--
|
|
Installer downloads: serve /installers/* as IIS static files instead of
|
|
forwarding them to Flask. The handler above is path="*", so without this a
|
|
request for /installers/Foo.exe goes to waitress, which has no such route
|
|
(SPA fallback), and large binaries would stream through a Python thread.
|
|
|
|
This <location> clears the httpPlatformHandler for that one subpath and puts
|
|
the static file handler back, so IIS serves the bytes directly (kernel-mode,
|
|
range/resume, no Python thread held).
|
|
|
|
Requires a physical folder at APP_ROOT\installers (the site's physical path
|
|
is APP_ROOT). Drop the installer binaries there, e.g. robocopy them from the
|
|
classic wwwroot\installers. The stored installpath 'installers/Foo.exe' then
|
|
resolves to <mount>/installers/Foo.exe (e.g. /shopdb/installers/Foo.exe).
|
|
|
|
.exe/.msi are given an explicit MIME map; if the parent site has a Request
|
|
Filtering rule that denies executable extensions, also allow them there.
|
|
-->
|
|
<location path="installers">
|
|
<system.webServer>
|
|
<handlers>
|
|
<clear />
|
|
<add name="StaticFile" path="*" verb="*"
|
|
modules="StaticFileModule" resourceType="File"
|
|
requireAccess="Read" />
|
|
</handlers>
|
|
<staticContent>
|
|
<remove fileExtension=".exe" />
|
|
<mimeMap fileExtension=".exe" mimeType="application/octet-stream" />
|
|
<remove fileExtension=".msi" />
|
|
<mimeMap fileExtension=".msi" mimeType="application/octet-stream" />
|
|
</staticContent>
|
|
</system.webServer>
|
|
</location>
|
|
</configuration>
|