{"id":22269106,"url":"https://github.com/diogofcunha/api-gateway-auth-policy","last_synced_at":"2025-08-19T04:34:27.597Z","repository":{"id":43993105,"uuid":"240378593","full_name":"diogofcunha/api-gateway-auth-policy","owner":"diogofcunha","description":"AWS auth policy generator for API gateways lambda authorizers ","archived":false,"fork":false,"pushed_at":"2024-06-18T02:44:13.000Z","size":864,"stargazers_count":6,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-09T11:42:25.547Z","etag":null,"topics":["api-gateway","api-gateway-custom-authorizer","authorization","aws","lambda","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diogofcunha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-13T22:24:49.000Z","updated_at":"2023-11-22T21:16:58.000Z","dependencies_parsed_at":"2023-02-03T17:30:58.141Z","dependency_job_id":null,"html_url":"https://github.com/diogofcunha/api-gateway-auth-policy","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogofcunha%2Fapi-gateway-auth-policy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogofcunha%2Fapi-gateway-auth-policy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogofcunha%2Fapi-gateway-auth-policy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogofcunha%2Fapi-gateway-auth-policy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diogofcunha","download_url":"https://codeload.github.com/diogofcunha/api-gateway-auth-policy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227905497,"owners_count":17837906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-gateway","api-gateway-custom-authorizer","authorization","aws","lambda","nodejs","typescript"],"created_at":"2024-12-03T11:15:08.503Z","updated_at":"2024-12-03T11:15:09.004Z","avatar_url":"https://github.com/diogofcunha.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# api-gateway-auth-policy\n\n[![CircleCI](https://circleci.com/gh/diogofcunha/api-gateway-auth-policy.svg?style=svg)](https://circleci.com/gh/diogofcunha/api-gateway-auth-policy)\n[![npm package][npm-badge]][npm]\n\n[npm-badge]: https://img.shields.io/npm/v/api-gateway-auth-policy.png?style=flat-square\n[npm]: https://www.npmjs.com/package/api-gateway-auth-policy\n\n\u003cimg src=\"https://user-images.githubusercontent.com/10208017/74596965-8529c600-504e-11ea-803e-b24920087fa4.png\" width=\"300\" /\u003e\n\nThis package aims to solve the problem of generating AWS auth policies for API gateways lambda authorizers.\nAuthorizers an easy and combinient way to secure your aws lambda invokations, to find more about it consult [aws docs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html).\n\nBeing written in typescript, this package aims to be 100% type safe, avoiding common mistakes and being self documented.\n\n## Install\n\n```shell\nyarn add api-gateway-auth-policy\n```\n\n## Usage example\n\nThe public methods exposed by the api are all chainable.\n\n```typescript\nconst optionalConfig = {\n  region: 'eu-west-1',\n  stage: 'production',\n  apiId: 'xxxxxxxxxx',\n};\n\nconst accountId = '12345';\n\nnew ApiGatewayAuthPolicy(accountId, optionalConfig)\n  .allowMethod(HttpVerb.GET, '/media', {\n    StringEquals: {'aws:username': 'johndoe'},\n  })\n  .allowMethod(HttpVerb.PATCH, '/media')\n  .allowMethod(HttpVerb.POST, '/media')\n  .denyMethod(HttpVerb.DELETE, '/media')\n  .denyMethod(HttpVerb.PUT, '/media', {\n    IpAddress: {\n      'aws:SourceIp': ['203.0.113.0/24', '2001:DB8:1234:5678::/64'],\n    },\n  })\n  .render('principalId');\n```\n\n## Generated policy example\n\n```json\n{\n  \"context\": {\n    \"isSecured\": true,\n    \"name\": \"diogo\"\n  },\n  \"policyDocument\": {\n    \"Statement\": [\n      {\n        \"Action\": \"execute-api:Invoke\",\n        \"Condition\": {\n          \"StringEquals\": {\n            \"aws:username\": \"johndoe\"\n          }\n        },\n        \"Effect\": \"Allow\",\n        \"Resource\": [\"arn:aws:execute-api:*:12345:*:*:GET:/media\"]\n      },\n      {\n        \"Action\": \"execute-api:Invoke\",\n        \"Effect\": \"Allow\",\n        \"Resource\": [\"arn:aws:execute-api:*:12345:*:*:PATCH:/media\", \"arn:aws:execute-api:*:12345:*:*:POST:/media\"]\n      },\n      {\n        \"Action\": \"execute-api:Invoke\",\n        \"Condition\": {\n          \"IpAddress\": {\n            \"aws:SourceIp\": [\"203.0.113.0/24\", \"2001:DB8:1234:5678::/64\"]\n          }\n        },\n        \"Effect\": \"Deny\",\n        \"Resource\": [\"arn:aws:execute-api:*:12345:*:*:PUT:/media\"]\n      },\n      {\n        \"Action\": \"execute-api:Invoke\",\n        \"Effect\": \"Deny\",\n        \"Resource\": [\"arn:aws:execute-api:*:12345:*:*:DELETE:/media\"]\n      }\n    ],\n    \"Version\": \"2012-10-17\"\n  },\n  \"principalId\": \"*\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiogofcunha%2Fapi-gateway-auth-policy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiogofcunha%2Fapi-gateway-auth-policy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiogofcunha%2Fapi-gateway-auth-policy/lists"}