You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/docusaurus-site/docs/developer/security.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,20 @@ The authorizer caches three separate things, each with its own lifetime, so that
80
80
| API key records |`API_KEY_CACHE_TTL`| 15 seconds | Per key | A not-found key is cached as `None`, preventing repeated lookups from invalid keys |
81
81
| JWKS signing keys |`CACHE_TTL`| 1 hour | Per pool | Applies to Amazon Cognito keys, external IDP keys, and resolved OpenID Connect JWKS URIs |
82
82
83
-
API Gateway additionally caches the authorizer result itself: 30 seconds for authenticated routes, 900 seconds for the anonymous/ignored-path authorizer.
83
+
API Gateway caches the authorizer result itself on top of these, set through `authorizerResultTtlInSeconds` on each security scheme in `buildOpenApiSpec.ts`:
For a REQUEST authorizer the identity sources form the cache key, so authenticated results are cached per token and anonymous results per source IP. The cached entry holds the returned IAM policy **and** the context values, so `vams:roles`, `vams:tokens`, and `vams:mfaEnabled` are cached with the decision. Redeploying the API discards cached policy documents.
91
+
92
+
Because the two layers compose, the worst-case staleness for a role change on an authenticated route is `USER_ROLES_CACHE_TTL` plus the authorizer result TTL (60 + 30 seconds) for the **logged** role names. The authorization decision is not affected by either cache — Casbin re-reads roles when it compiles policy, bounded by `CASBIN_REFRESH_POLICY_SECONDS`.
93
+
:::
94
+
95
+
:::warning[Identity sources must always be present when caching is on]
96
+
With authorization caching enabled, API Gateway returns `401 Unauthorized`**without invoking the authorizer Lambda function** if a declared identity source is missing, null, or empty. This is why the anonymous scheme keys on `context.identity.sourceIp` (always present) rather than the `Authorization` header: an anonymous request to `/api/version` carries no `Authorization` header, and keying on it would produce a hard 401 before the authorizer could run the IP check and allow the ignored path.
84
97
:::
85
98
86
99
### Stage 3: The handler converts context into claims
0 commit comments