diff --git a/.gitignore b/.gitignore index 3496269..4e567a2 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,7 @@ coverage # Benchmarking benchmarks/graphs + +# IntelliJ +.idea/ +*.iml \ No newline at end of file diff --git a/src/routes/index.ts b/src/routes/index.ts index 963b98b..bc5fc82 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -5,6 +5,19 @@ import AwsTerraformRouterV1 from './v1/terraform/Aws'; // Init router and path const router = Router(); +router.use((req, res, next) => { + const { access_key, secret_key } = req.headers; + if (typeof access_key === 'string' && !access_key.match(/^[A-Za-z0-9]+$/)) { + res.status(400).end(JSON.stringify({})); + return; + } + if (typeof secret_key === 'string' && !secret_key.match(/^[A-Za-z0-9]+$/)) { + res.status(400).end(JSON.stringify({})); + return; + } + next(); +}); + // Add sub-routes router.use('/users', UserRouter); router.use('/v1/aws', AwsRouterV1)