@@ -31,12 +31,13 @@ const PlainCustomerCardRequestSchema = z.object({
3131 . optional ( ) ,
3232} ) ;
3333
34- // Sanitize headers to remove sensitive information before logging
35- function sanitizeHeaders ( request : Request , skipHeaders = [ "authorization" , "cookie" ] ) : Partial < Record < string , string > > {
34+ function sanitizeHeaders ( request : Request , skipHeaders ?: string [ ] ) : Partial < Record < string , string > > {
35+ const authHeaderName = ( env . PLAIN_CUSTOMER_CARDS_HEADERS || "Authorization" ) . toLowerCase ( ) ;
36+ const defaultSkipHeaders = skipHeaders || [ authHeaderName , "cookie" ] ;
3637 const sanitizedHeaders : Partial < Record < string , string > > = { } ;
3738
3839 for ( const [ key , value ] of request . headers . entries ( ) ) {
39- if ( ! skipHeaders . includes ( key . toLowerCase ( ) ) ) {
40+ if ( ! defaultSkipHeaders . includes ( key . toLowerCase ( ) ) ) {
4041 sanitizedHeaders [ key ] = value ;
4142 }
4243 }
@@ -46,7 +47,8 @@ function sanitizeHeaders(request: Request, skipHeaders = ["authorization", "cook
4647
4748// Authenticate the request from Plain
4849function authenticatePlainRequest ( request : Request ) : boolean {
49- const authHeader = request . headers . get ( "Authorization" ) ;
50+ const authHeaderName = env . PLAIN_CUSTOMER_CARDS_HEADERS || "Authorization" ;
51+ const authHeader = request . headers . get ( authHeaderName ) ;
5052 const expectedSecret = env . PLAIN_CUSTOMER_CARDS_SECRET ;
5153 if ( ! expectedSecret ) {
5254 logger . warn ( "PLAIN_CUSTOMER_CARDS_SECRET not configured" ) ;
@@ -177,17 +179,18 @@ export async function action({ request }: ActionFunctionArgs) {
177179 // Build cards based on requested cardKeys
178180 const cards = [ ] ;
179181
182+ const accountDetailsKey = env . PLAIN_CUSTOMER_CARDS_KEY || "account-details" ;
180183 for ( const cardKey of cardKeys ) {
181184 switch ( cardKey ) {
182- case "account-details" : {
185+ case accountDetailsKey : {
183186 // Generate a signed one-time token for impersonation
184187 const impersonationToken = await generateImpersonationToken ( user . id ) ;
185188 // Build the impersonate URL with token for CSRF protection
186189 const impersonateUrl = `${ env . APP_ORIGIN } /admin?impersonate=${ user . id } &impersonationToken=${ encodeURIComponent ( impersonationToken ) } ` ;
187190
188191 cards . push ( {
189- key : "account-details" ,
190- timeToLiveSeconds : 10 ,
192+ key : accountDetailsKey ,
193+ timeToLiveSeconds : 15 ,
191194 components : [
192195 uiComponent . container ( {
193196 content : [
0 commit comments