Skip to content

mod_authn_socache: keep cache entries separate per AuthType, AuthName, provider and server port - #1049

Open
notroj wants to merge 2 commits into
apache:trunkfrom
notroj:authn-socache-key-binding
Open

notroj wants to merge 2 commits into
apache:trunkfrom
notroj:authn-socache-key-binding

Conversation

@notroj

@notroj notroj commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

This is #930 rebased onto trunk and squashed into one commit, plus follow-up changes from review; the AuthType change is a second commit.

The cache key now includes the AuthName for Basic as well as Digest, the name of the authn provider which stored the entry, and the AuthType. With the directory and server values of AuthnCacheContext it also includes the server's port. Locations which differ in any of these no longer share cache entries.

Changes from #930:

  • The port in the key is the one configured for the server, not ap_get_server_port(). The latter takes the port from the Host header by default, which let a client miss the cache at will and store an entry per port.
  • AuthType is added to the key, since a Basic entry and a Digest entry for the same user and realm are of no use to each other.
  • The tests are folded into test_016_authn_socache.py, which trunk has gained since, and extended to cover the provider, port and AuthType parts of the key.
  • The CHANGES entry is moved to changes-entries/.

This changes behaviour for a custom AuthnCacheContext too: locations sharing one now share entries only where their AuthType, AuthName and provider also match.

🤖 Generated with Claude Code

0xABCD01 and others added 2 commits November 17, 2026 10:34
authn provider and server port:

* modules/aaa/mod_authn_socache.c (construct_key): Take the provider
  name. Add it, the AuthName for Basic auth, and for the "directory"
  and "server" contexts the port configured for the server, to the
  key.
  (ap_authn_cache_store): Pass the provider name.
  (check_password, get_realm_hash): Try the key for each provider
  cached for.

* docs/manual/mod/mod_authn_socache.xml: Update AuthnCacheContext to
  match.

* test/modules/aaa/test_016_authn_socache.py
  (_SocacheBase.url, _SocacheBase.basic): Take a port.
  (TestAuthnSocache._class_scope): Add locations and a second server
  for the tests below.
  (TestAuthnSocache.test_authn_socache_175_files_authname,
  TestAuthnSocache.test_authn_socache_176_second_provider,
  TestAuthnSocache.test_authn_socache_177_host_port,
  TestAuthnSocache.test_authn_socache_178_server_port): New tests.

* changes-entries/authn_socache_key.txt: New file.

Submitted by: Hafiar <289389248+0xABCD01 users.noreply.github.com>
Reviewed by: jorton (committed with changes)
Github: closes apache#930

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* modules/aaa/mod_authn_socache.c (construct_key): Add the lower-cased
  AuthType to the key.

* docs/manual/mod/mod_authn_socache.xml: Document it.

* test/modules/aaa/test_016_authn_socache.py
  (TestAuthnSocache._class_scope): Add Basic and Digest locations
  sharing a context and AuthName.
  (TestAuthnSocache.test_authn_socache_179_auth_type): New test.

* changes-entries/authn_socache_key.txt: Update.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@notroj
notroj force-pushed the authn-socache-key-binding branch from dc9e8e8 to 9ed68fe Compare November 17, 2026 11:33
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