express-tailscale-auth
Version:
Express middleware for Tailscale authentication
1 lines • 1.51 kB
Source Map (JSON)
{"version":3,"sources":["../../src/utils/checkTrustProxyConfig.ts"],"names":["checkTrustProxyConfiguration","req","trustProxy"],"mappings":"aAEO,IAAMA,CAAgCC,CAAAA,CAAAA,EAAiB,CAC1D,IAAMC,CAAaD,CAAAA,CAAAA,CAAI,GAAI,CAAA,GAAA,CAAI,aAAa,CAAA,CAO5C,OANwB,CAAC,EACvBA,CAAI,CAAA,OAAA,CAAQ,iBAAiB,CAAA,EAC7BA,CAAI,CAAA,OAAA,CAAQ,kBAAkB,CAAA,EAC9BA,CAAI,CAAA,OAAA,CAAQ,mBAAmB,CAAA,CAAA,GAGTC,CAAe,GAAA,KAAA,EAASA,CAAe,GAAA,MAAA,CAAA,EAC7D,QAAQ,IAAK,CAAA;AAAA;;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA,CAalB,CAAA,CACM,MAEI,KACT","file":"checkTrustProxyConfig.cjs","sourcesContent":["import type { Request } from \"express\"\n\nexport const checkTrustProxyConfiguration = (req: Request) => {\n const trustProxy = req.app.get('trust proxy')\n const hasProxyHeaders = !!(\n req.headers['x-forwarded-for'] || \n req.headers['x-forwarded-host'] || \n req.headers['x-forwarded-proto']\n )\n\n if (hasProxyHeaders && (trustProxy === false || trustProxy === undefined)) {\n console.warn(`\n⚠️ Tailscale Auth Middleware Warning ⚠️\n\nDetected X-Forwarded-* headers but Express 'trust proxy' is not configured.\nThis may result in incorrect IP address detection and authentication failures.\n\nTo fix this, add one of the following to your Express app:\n\n // For most reverse proxy setups (recommended)\n app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal'])\n \n\nSee: https://expressjs.com/en/guide/behind-proxies.html\n`)\nreturn true\n }\n return false\n }"]}