fix(api): prevent cross-instance caching of well-known app link files (#12644)

# Which Problems Are Solved

The `/.well-known/apple-app-site-association` and
`/.well-known/assetlinks.json` responses are instance specific: the body
depends on the requested host. The responses did not declare this, so a
shared cache whose cache key does not include the host could store one
instance's file and serve it on another instance's domain. This could
result in a wrong or empty file being returned intermittently, breaking
native passkey verification.

Dropping the `public` directive (#12634) was not sufficient: depending
on its cache mode, a shared cache may store any response carrying a
`max-age`.

The docs page for native app links also still documented the old
`Cache-Control: public` header and only the single `get_login_creds`
relation (missing `handle_all_urls`, added in #12634).

# How the Problems Are Solved

- Send **`Vary: Host`** on both well-known responses, declaring that the
body depends on the host: a spec-compliant shared cache must store
per-host variants or skip caching. Clients addressing a single host (the
Apple and Google verifiers, browsers) are unaffected and keep honoring
the configured `max-age`.
- Correct the outdated caching reasoning in the code comments.
- Guard the header with unit and integration tests.
- Update the native app links docs page: both Digital Asset Links
relations and the current response headers.

# Additional Changes

None. `WellKnown.AppLinksCacheControlMaxAge` behavior is unchanged (`0`
still results in `no-store`).

# Additional Context

- Follow-up to #12634; relates to #12497.
- Verified with interleaved requests against two instances: responses
are no longer reused across domains, and each domain consistently serves
its own configuration.
- To be cherry-picked to `v4.x` from `main` once merged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
Livio Spring
2026-08-26 10:57:28 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 6fdb74593c
commit c9d747d407
11 changed files with 60 additions and 131 deletions
+2 -2
View File
@@ -181,12 +181,12 @@ message OIDCConfig {
];
IOSAppLinkConfig ios = 23 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "iOS Associated Domains / passkey trust config. Served in /.well-known/apple-app-site-association as webcredentials.apps entry \"{team_id}.{bundle_id}\" (Apple's full App ID). That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer; changes can take time to take effect.";
description: "iOS Associated Domains / passkey trust config. Served in /.well-known/apple-app-site-association as webcredentials.apps entry \"{team_id}.{bundle_id}\" (Apple's full App ID). Platform verifiers may cache the file; changes can take time to take effect.";
}
];
AndroidAppLinkConfig android = 24 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Android Digital Asset Links / passkey trust config. Served in /.well-known/assetlinks.json for delegate_permission/common.get_login_creds. That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer; changes can take time to take effect.";
description: "Android Digital Asset Links / passkey trust config. Served in /.well-known/assetlinks.json for delegate_permission/common.handle_all_urls and delegate_permission/common.get_login_creds. Platform verifiers may cache the file; changes can take time to take effect.";
}
];
}
@@ -345,14 +345,12 @@ message CreateOIDCApplicationRequest {
// IOS is iOS Associated Domains / passkey trust config.
// Served in /.well-known/apple-app-site-association as webcredentials.apps entry
// "{team_id}.{bundle_id}" (Apple's full App ID = Team ID prefix + Bundle ID).
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Platform verifiers may cache the file; changes can take time to take effect.
IOSAppLinkConfig ios = 18;
// Android is Android Digital Asset Links / passkey trust config.
// Served in /.well-known/assetlinks.json for delegate_permission/common.get_login_creds.
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Served in /.well-known/assetlinks.json for delegate_permission/common.handle_all_urls and delegate_permission/common.get_login_creds.
// Platform verifiers may cache the file; changes can take time to take effect.
AndroidAppLinkConfig android = 19;
}
@@ -595,15 +593,13 @@ message UpdateOIDCApplicationConfigurationRequest {
// IOS is iOS Associated Domains / passkey trust config.
// Served in /.well-known/apple-app-site-association as webcredentials.apps entry
// "{team_id}.{bundle_id}" (Apple's full App ID = Team ID prefix + Bundle ID).
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Platform verifiers may cache the file; changes can take time to take effect.
// If not set, the iOS config will not be changed.
optional IOSAppLinkConfig ios = 18;
// Android is Android Digital Asset Links / passkey trust config.
// Served in /.well-known/assetlinks.json for delegate_permission/common.get_login_creds.
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Served in /.well-known/assetlinks.json for delegate_permission/common.handle_all_urls and delegate_permission/common.get_login_creds.
// Platform verifiers may cache the file; changes can take time to take effect.
// If not set, the Android config will not be changed.
optional AndroidAppLinkConfig android = 19;
}
+6 -10
View File
@@ -162,22 +162,19 @@ message OIDCConfiguration {
// IOS is iOS Associated Domains / passkey trust config.
// Served in /.well-known/apple-app-site-association as webcredentials.apps entry
// "{team_id}.{bundle_id}" (Apple's full App ID = Team ID prefix + Bundle ID).
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Platform verifiers may cache the file; changes can take time to take effect.
IOSAppLinkConfig ios = 22;
// Android is Android Digital Asset Links / passkey trust config.
// Served in /.well-known/assetlinks.json for delegate_permission/common.get_login_creds.
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Served in /.well-known/assetlinks.json for delegate_permission/common.handle_all_urls and delegate_permission/common.get_login_creds.
// Platform verifiers may cache the file; changes can take time to take effect.
AndroidAppLinkConfig android = 23;
}
// IOSAppLinkConfig is iOS Associated Domains / passkey trust config.
// Served in /.well-known/apple-app-site-association as webcredentials.apps entry
// "{team_id}.{bundle_id}" (Apple's full App ID = Team ID prefix + Bundle ID).
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Platform verifiers may cache the file; changes can take time to take effect.
message IOSAppLinkConfig {
// TeamID is the Apple Developer Team ID (exactly 10 alphanumeric characters), e.g. ABCDE12345.
// From Apple Developer account membership — not the Bundle ID.
@@ -191,9 +188,8 @@ message IOSAppLinkConfig {
}
// AndroidAppLinkConfig is Android Digital Asset Links / passkey trust config.
// Served in /.well-known/assetlinks.json for delegate_permission/common.get_login_creds.
// That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer;
// changes can take time to take effect.
// Served in /.well-known/assetlinks.json for delegate_permission/common.handle_all_urls and delegate_permission/common.get_login_creds.
// Platform verifiers may cache the file; changes can take time to take effect.
message AndroidAppLinkConfig {
// PackageName is the Android applicationId / package name from the app manifest.
// Empty clears the value on update.
+4 -4
View File
@@ -10384,12 +10384,12 @@ message AddOIDCAppRequest {
];
zitadel.app.v1.IOSAppLinkConfig ios = 20 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "iOS Associated Domains / passkey trust config. Served in /.well-known/apple-app-site-association as webcredentials.apps entry \"{team_id}.{bundle_id}\" (Apple's full App ID). That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer; changes can take time to take effect.";
description: "iOS Associated Domains / passkey trust config. Served in /.well-known/apple-app-site-association as webcredentials.apps entry \"{team_id}.{bundle_id}\" (Apple's full App ID). Platform verifiers may cache the file; changes can take time to take effect.";
}
];
zitadel.app.v1.AndroidAppLinkConfig android = 21 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Android Digital Asset Links / passkey trust config. Served in /.well-known/assetlinks.json for delegate_permission/common.get_login_creds. That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer; changes can take time to take effect.";
description: "Android Digital Asset Links / passkey trust config. Served in /.well-known/assetlinks.json for delegate_permission/common.handle_all_urls and delegate_permission/common.get_login_creds. Platform verifiers may cache the file; changes can take time to take effect.";
}
];
}
@@ -10585,12 +10585,12 @@ message UpdateOIDCAppConfigRequest {
];
zitadel.app.v1.IOSAppLinkConfig ios = 19 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "iOS Associated Domains / passkey trust config. Served in /.well-known/apple-app-site-association as webcredentials.apps entry \"{team_id}.{bundle_id}\" (Apple's full App ID). That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer; changes can take time to take effect.";
description: "iOS Associated Domains / passkey trust config. Served in /.well-known/apple-app-site-association as webcredentials.apps entry \"{team_id}.{bundle_id}\" (Apple's full App ID). Platform verifiers may cache the file; changes can take time to take effect.";
}
];
zitadel.app.v1.AndroidAppLinkConfig android = 20 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Android Digital Asset Links / passkey trust config. Served in /.well-known/assetlinks.json for delegate_permission/common.get_login_creds. That response may be HTTP-cached (Cache-Control), and platform verifiers may cache longer; changes can take time to take effect.";
description: "Android Digital Asset Links / passkey trust config. Served in /.well-known/assetlinks.json for delegate_permission/common.handle_all_urls and delegate_permission/common.get_login_creds. Platform verifiers may cache the file; changes can take time to take effect.";
}
];
}