mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
Storing the full OIDC id_token in the `oidcIdToken` cookie inflated the sign-in response headers enough to exceed reverse proxy buffers, causing a 502 Bad Gateway. Store the id_token server-side in Redis keyed by a short session identifier and keep only that identifier in the cookie, preserving spec-compliant RP-initiated logout via `id_token_hint`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
84 lines
2.3 KiB
TypeScript
84 lines
2.3 KiB
TypeScript
/**
|
|
* Helper class for Redis cache key generation.
|
|
*/
|
|
export class RedisPrefixHelper {
|
|
/**
|
|
* Gets key against which unfurl response for the given url is stored.
|
|
*
|
|
* @param teamId The team ID to generate a key for.
|
|
* @param url The url to generate a key for.
|
|
*/
|
|
public static getUnfurlKey(teamId: string, url = "") {
|
|
return `unfurl:${teamId}:${url}`;
|
|
}
|
|
|
|
/**
|
|
* Gets key for caching collection documents structure.
|
|
*
|
|
* @param collectionId The collection ID to generate a key for.
|
|
* @returns the cache key string.
|
|
*/
|
|
public static getCollectionDocumentsKey(collectionId: string) {
|
|
return `cd:${collectionId}`;
|
|
}
|
|
|
|
/**
|
|
* Gets key for caching embed check results. This is a global cache key
|
|
* (not team-specific) since embed headers are the same for all users.
|
|
*
|
|
* @param url The URL to generate a cache key for.
|
|
* @returns the cache key string.
|
|
*/
|
|
public static getEmbedCheckKey(url: string) {
|
|
return `embed:${url}`;
|
|
}
|
|
|
|
/**
|
|
* Gets key for caching a user's accessible collection IDs.
|
|
*
|
|
* @param userId The user ID to generate a key for.
|
|
* @returns the cache key string.
|
|
*/
|
|
public static getUserCollectionIdsKey(userId: string) {
|
|
return `uc:${userId}`;
|
|
}
|
|
|
|
/**
|
|
* Gets key for caching a team's enabled webhook subscriptions.
|
|
*
|
|
* @param teamId The team ID to generate a key for.
|
|
* @returns the cache key string.
|
|
*/
|
|
public static getWebhookSubscriptionsKey(teamId: string) {
|
|
return `whs:${teamId}`;
|
|
}
|
|
|
|
/**
|
|
* Gets key for caching the count of a relationship managed by the
|
|
* `CounterCache` decorator.
|
|
*
|
|
* @param modelName The owning model name (e.g. "Group").
|
|
* @param relationName The relationship reference name (e.g. "members").
|
|
* @param id The owning record id.
|
|
* @returns the cache key string.
|
|
*/
|
|
public static getCounterCacheKey(
|
|
modelName: string,
|
|
relationName: string,
|
|
id: string
|
|
) {
|
|
return `count:${modelName}:${relationName}:${id}`;
|
|
}
|
|
|
|
/**
|
|
* Gets key for storing an OIDC id_token used as the `id_token_hint` during
|
|
* RP-initiated logout, referenced by a short session identifier.
|
|
*
|
|
* @param sessionId The logout session identifier to generate a key for.
|
|
* @returns the cache key string.
|
|
*/
|
|
public static getLogoutTokenKey(sessionId: string) {
|
|
return `oidc:logout:${sessionId}`;
|
|
}
|
|
}
|