File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,14 @@ import { logger } from './logger.js'
5
5
const JWT_SECRET = process . env . JWT_SECRET
6
6
7
7
export function logIncomingAuth ( req : Request , res : Response , next : NextFunction ) {
8
- logger . debug ( 'Incoming headers:' , req . headers )
8
+ logger . info (
9
+ `[AUTH] ${ req . headers [ 'cf-connecting-ip' ] ?? req . ip } - ${ req . headers [ 'cf-ipcountry' ] ?? 'unknown country' } `
10
+ )
9
11
10
12
const authHeader = req . headers . authorization
11
13
if ( ! authHeader ?. startsWith ( 'Bearer ' ) ) {
12
14
logger . warn ( 'No auth header or bad format' )
15
+ logger . debug ( 'Incoming headers:' , req . headers )
13
16
} else {
14
17
const token = authHeader . split ( ' ' ) [ 1 ]
15
18
logger . debug ( 'Inspecting token:' , token )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { Response } from 'express'
6
6
export const rateLimiter : RateLimitRequestHandler = rateLimit ( {
7
7
windowMs : 60 * 1000 ,
8
8
limit : ( req : Request ) : number => {
9
- logger . debug ( `Rate limit check ${ req . auth ? 'authenticated' : 'anon' } - ${ req . headers [ 'cf-connecting-ip' ] ?? req . ip } ` )
9
+ logger . info ( `Rate limit check ${ req . auth ? 'authenticated' : 'anon' } - ${ req . headers [ 'cf-connecting-ip' ] ?? req . ip } ` )
10
10
return req . auth ? 60 : 5 // 60 req/min for auth, 5 for anon
11
11
} ,
12
12
keyGenerator : ( req : Request ) : string => {
You can’t perform that action at this time.
0 commit comments