Skip to content

Extract HTTPS and HTTP authentication requirement into a drop-in library - #14

Open
codeling wants to merge 2 commits into
mainfrom
claude/gracious-cray-2rig3n
Open

codeling wants to merge 2 commits into
mainfrom
claude/gracious-cray-2rig3n

Conversation

@codeling

@codeling codeling commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • New basic-auth/ directory, self-contained and copyable into other apps:
    • basic-auth.php: basicAuthRequire() stops requests (403) that did not arrive over HTTPS or that the web server did not authenticate (REMOTE_USER). Returns the user name. Options for disabling either check, trusting X-Forwarded-Proto (off by default), HSTS, log prefix and client messages. Rejections are logged at most once per minute. Also basicAuthIsHttps() / basicAuthUser().
    • htaccess.sample, nginx.conf.sample: generic web server parts (Basic auth + HTTPS only), consistent with the app's own samples.
    • README.md: install steps and options.
  • The todo app uses it from todo-core.php (passing $trust_forwarded_proto); session.php uses basicAuthIsHttps() for the cookie secure flag.
  • Behaviour change: the app now also rejects plain HTTP requests in PHP (before, only the web server config enforced HTTPS). $require_https = false in config.php switches this off for local development/tests; CI config and docs are updated. New HTTPS_REQUIRED strings (en/de).
  • .htaccess / nginx sample / Apache access test deny the new library files.
  • Merged main (incl. Security hardening: tag injection, auth ordering, session and header fixes #15: forwarded header no longer trusted by default, throttled logging) and aligned the library with it.

Testing

  • node --test tests/basic-auth.test.js tests/auth.test.js: 17/17 pass locally.
  • CI (integration, php-lint, apache-access, vendor-up-to-date, CodeQL) is green on the current head.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ERh53iPbYAoCQPkBXezdGQ

claude added 2 commits October 5, 2026 20:51
…library

basic-auth/ contains the PHP guard (basic-auth.php), generic Apache and
nginx samples and a README, so it can be copied into other apps. The todo
app now uses it, and thereby also rejects plain HTTP requests in PHP
($require_https = false switches that off for local development and tests).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ERh53iPbYAoCQPkBXezdGQ
Main stopped believing X-Forwarded-Proto by default and throttles the log of
rejected requests; the library now does the same (trust_forwarded_proto
defaults to false, rejections are logged at most once per minute) and the
application passes $trust_forwarded_proto to it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ERh53iPbYAoCQPkBXezdGQ
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