Skip to content

Commit 0d9f057

Browse files
committed
one time impersonation fix
1 parent d2b9ca1 commit 0d9f057

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

apps/webapp/app/routes/api.v1.plain.customer-cards.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ const PlainCustomerCardRequestSchema = z.object({
2323
.optional(),
2424
});
2525

26+
// Sanitize headers to remove sensitive information before logging
27+
function sanitizeHeaders(request: Request, skipHeaders = ["authorization", "cookie"]): Partial<Record<string, string>> {
28+
const sanitizedHeaders: Partial<Record<string, string>> = {};
29+
30+
for (const [key, value] of request.headers.entries()) {
31+
if (!skipHeaders.includes(key.toLowerCase())) {
32+
sanitizedHeaders[key] = value;
33+
}
34+
}
35+
36+
return sanitizedHeaders;
37+
}
38+
2639
// Authenticate the request from Plain
2740
function authenticatePlainRequest(request: Request): boolean {
2841
const authHeader = request.headers.get("Authorization");
@@ -58,7 +71,7 @@ export async function action({ request }: ActionFunctionArgs) {
5871
// Authenticate the request
5972
if (!authenticatePlainRequest(request)) {
6073
logger.warn("Unauthorized Plain customer card request", {
61-
headers: Object.fromEntries(request.headers.entries()),
74+
headers: sanitizeHeaders(request),
6275
});
6376
return json({ error: "Unauthorized" }, { status: 401 });
6477
}
@@ -166,7 +179,7 @@ export async function action({ request }: ActionFunctionArgs) {
166179

167180
cards.push({
168181
key: "account-details",
169-
timeToLiveSeconds: 300, // Cache for 5 minutes
182+
timeToLiveSeconds: 10,
170183
components: [
171184
uiComponent.container({
172185
content: [

0 commit comments

Comments
 (0)