{"id":23663459,"url":"https://github.com/eyolas/kong-plugin-middleman-advanced","last_synced_at":"2025-04-10T19:25:31.656Z","repository":{"id":67394542,"uuid":"262009239","full_name":"eyolas/kong-plugin-middleman-advanced","owner":"eyolas","description":"PLUGIN KONG: A Kong plugin that enables you to make multiple extra HTTP POST request before calling an API.","archived":false,"fork":false,"pushed_at":"2021-02-23T14:14:19.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T17:01:54.140Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eyolas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-07T09:37:54.000Z","updated_at":"2023-03-10T08:05:08.000Z","dependencies_parsed_at":"2023-06-11T00:45:16.496Z","dependency_job_id":null,"html_url":"https://github.com/eyolas/kong-plugin-middleman-advanced","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyolas%2Fkong-plugin-middleman-advanced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyolas%2Fkong-plugin-middleman-advanced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyolas%2Fkong-plugin-middleman-advanced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyolas%2Fkong-plugin-middleman-advanced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eyolas","download_url":"https://codeload.github.com/eyolas/kong-plugin-middleman-advanced/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281388,"owners_count":21077423,"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":[],"created_at":"2024-12-29T05:28:27.135Z","updated_at":"2025-04-10T19:25:31.627Z","avatar_url":"https://github.com/eyolas.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kong Middleman advanced\n\nA Kong plugin that enables an extra HTTP POST requests before proxying the original.\n\nbased on https://github.com/pantsel/kong-middleman-plugin and https://github.com/mdemou/kong-middleman\n\n\n\n## Description\n\nIn some cases, you may need to validate a request to a separate server or service using custom logic before Kong proxies it to your API.\nMiddleman enables you to do that by allowing you to make an extra HTTP requests before calling an API endpoint.\n\n## Change from the original plugin\n\nlist of change :\n- Update for kong v2\n- move json.lua to https://github.com/rxi/json.lua\n- Update schema for v2\n\t- add config for include certificate (default false)\n    - add config for include credential (default false)\n    - add config for include route (default false)\n    - add config for include consumer (default false)\n - change payload :\n \t- add certificate (resty_kong_tls.get_full_client_certificate_chain())\n    - add credential (kong.client.get_credential())\n    - add route (kong.router.get_route() and kong.router.get_service())\n    - add consumer (kong.client.get_consumer())\n    - rename uri_args to params\n    - rename body data to body\n    - no json.encode if headers[\"content-type\"] == 'application/json'\n    - move body, headers and params in request field\n\n\npayload :\n```lua\nlocal payload = {\n    ['certificate'] = certificate,\n    ['consumer'] = consumer,\n    ['credential'] = credential,\n    ['kong_routing'] = kong_routing,\n    ['request'] = {\n      ['headers'] = headers,\n      ['params'] = params,\n      ['body'] = json_body,\n    }\n  }\n```\n\n## Installation\n\nWIP\n\n## Configuration\n\nYou can add the plugin on top of an API by executing the following request on your Kong server:\n\n```sh\n$ http POST :8001/services/{api}/plugins name=middleman-advanced config:='{ \"services\": [{\"url\": \"http://myserver.io/validate\", \"response\": \"table\", \"timeout\": 10000, \"keepalive\": 60000}]}'\n```\n\n\u003ctable\u003e\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eform parameter\u003c/th\u003e\n\u003cth\u003edefault\u003c/th\u003e\n\u003cth\u003edescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eThe name of the plugin to use, in this case: \u003ccode\u003emiddleman\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003econfig.services\u003c/code\u003e\u003cbr\u003e\u003cem\u003erequired\u003c/em\u003e\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eThe list of services witch the plugin make a JSON \u003ccode\u003ePOST\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003c/tbody\u003e\u003c/table\u003e\u003cbr /\u003e\n\n### Service config\n\u003ctable\u003e\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eform parameter\u003c/th\u003e\n\u003cth\u003edefault\u003c/th\u003e\n\u003cth\u003edescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003eurl\u003c/code\u003e\u003cbr\u003e\u003cem\u003erequired\u003c/em\u003e\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eThe URL to which the plugin will make a JSON \u003ccode\u003ePOST\u003c/code\u003e request before proxying the original request.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003eresponse\u003c/code\u003e\u003cbr\u003e\u003cem\u003erequired\u003c/em\u003e\u003c/td\u003e\n\u003ctd\u003etable\u003c/td\u003e\n\u003ctd\u003eThe type of response the middleman service is going to respond with\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003etimeout\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e10000\u003c/td\u003e\n\u003ctd\u003eTimeout (miliseconds) for the request to the URL specified above. Default value is 10000.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003ekeepalive\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e60000\u003c/td\u003e\n\u003ctd\u003eKeepalive time (miliseconds) for the request to the URL specified above. Default value is 60000.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003einclude_cert\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003efalse\u003c/td\u003e\n\u003ctd\u003eInclude the original certificate in JSON POST\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003einclude_credential\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003efalse\u003c/td\u003e\n\u003ctd\u003eInclude the credential in JSON POST\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003einclude_consumer\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003efalse\u003c/td\u003e\n\u003ctd\u003eInclude the consumer in JSON POST\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003einclude_route\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003efalse\u003c/td\u003e\n\u003ctd\u003eInclude the route in JSON POST\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\nMiddleman will execute a JSON \u003ccode\u003ePOST\u003c/code\u003e request to the specified \u003ccode\u003eurl\u003c/code\u003e with the following body:\n\nJSON POST\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eAttribute\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003ecertificate\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003csmall\u003eThe certificate of the original request if include_credential \u003cbr/\u003e see resty_kong_tls.get_full_client_certificate_chain()\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ccode\u003econsumer\u003c/code\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003csmall\u003eThe consumer of the original request \u003cbr/\u003e see kong.client.get_consumer()\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ccode\u003ecredential\u003c/code\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003csmall\u003eThe consumer of the original request \u003cbr/\u003e see kong.client.get_credential()\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ccode\u003ekong_routing\u003c/code\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003csmall\u003eThe kong_routing of the original request \u003cbr/\u003e see kong.router.get_route() and kong.router.get_service()\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ccode\u003erequest\u003c/code\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003csmall\u003eThe request of the original request \u003cbr /\u003e see the next table : request\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\nRequest\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eAttribute\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003ebody\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003csmall\u003eThe body of the original request\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ccode\u003eparams\u003c/code\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003csmall\u003eThe url arguments of the original request\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ccode\u003eheaders\u003c/code\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003csmall\u003eThe headers of the original request\u003c/small\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\nIn the scope of your own endpoint, you may validate any of these attributes and accept or reject the request according to your needs. If an HTTP response code of 299 or less is returned, the request is accepted. Any response code above 299 will cause the request to be rejected.  \n\n## Author\nDavid TOUZET\n\n## License\n\u003cpre\u003e\nThe MIT License (MIT)\n=====================\n\nCopyright (c) 2020 David TOUZET\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feyolas%2Fkong-plugin-middleman-advanced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feyolas%2Fkong-plugin-middleman-advanced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feyolas%2Fkong-plugin-middleman-advanced/lists"}