{"action":"created","comment":{"url":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/comments/192413401","pull_request_review_id":125189625,"id":192413401,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MjQxMzQwMQ==","diff_hunk":"@@ -0,0 +1,91 @@\n+import httpProxy from 'express-http-proxy'\n+import path from 'path'\n+\n+const routes = {\n+  group: /^\\/groups\\/(.*)\\/$/,\n+  pipelines: /^\\/(.*)\\/.*\\/pipelines\\.json$/,\n+  commits: /^\\/projects\\/(.*)\\%2F.*\\/repository\\/commits$/\n+}\n+\n+/**\n+ * Create a proxy for gitlab\n+ *\n+ * @param {Object} config The confiuration for the gitlab rpoxy\n+ * @returns {Object} Returns the configured proxy for gitlab\n+ * @author Jonas Cosandey (jonas.cosandey@adfinis-sygroup.ch)\n+ */\n+function createProxy(config) {\n+  return httpProxy(config.host, {\n+    /**\n+     * Define if the body of the request should be parsed or ignored.\n+     * We use it to prevent any requests which are not of type `GET`.\n+     *\n+     * @type Boolean\n+     * @author Jonas Cosandey (jonas.cosandey@adfinis-sygroup.ch)\n+     */\n+    parseReqBody: false,\n+\n+    /**\n+     * Filter the request according to their path.\n+     * If their path matches none of the ones defined in `routes` or the HTTP method is not `GET` they get rejected.\n+     *\n+     * @param {Object} req The request to validate\n+     * @returns {Boolean} Return `true` to let the request pass and `false` to deny the request.\n+     * @author Jonas Cosandey (jonas.cosandey@adfinis-sygroup.ch)\n+     */\n+    filter(req) {\n+      let namespace = Object.keys(routes)\n+        .map(key => {\n+          let match = req.path.match(routes[key])\n+\n+          // The fisrt element in the `match` array is the captured regex group.\n+          return match ? match[1] : null\n+        })\n+        .find(result => result)\n+\n+      return (\n+        req.method === 'GET' &&\n+        req.user.getGitlabGroups().some(group => {\n+          return group === namespace\n+        })\n+      )\n+    },\n+\n+    /**\n+     * Define the path on which the request should be proxied.\n+     * If it is the `pipelines` route, we dont want to prefix the path with the API namespace since this\n+     * is not a API request.\n+     *\n+     * @param {Object} req The request to validate\n+     * @returns {String} Returns the new path.\n+     * @author Jonas Cosandey (jonas.cosandey@adfinis-sygroup.ch)\n+     */\n+    proxyReqPathResolver(req) {\n+      let queryString = Object.keys(req.query)\n+        .map(key => `${key}=${req.query[key]}`)\n+        .join('&')\n+      if (req.path.match(routes.pipelines)) {\n+        return req.path\n+      }\n+\n+      if (queryString) {\n+        return `${path.join(config.prefix, req.path)}?${queryString}`\n+      }\n+      return path.join(config.prefix, req.path)\n+    },\n+\n+    /**\n+     * Append the gitlab token to the options for the new request.\n+     *\n+     * @param {Object} proxyReqOpts The options of the new request\n+     * @returns {Object} Returns the propperty object for the new request.\n+     *\n+     */\n+    proxyReqOptDecorator(proxyReqOpts) {\n+      proxyReqOpts.headers['private-token'] = config.token\n+      return proxyReqOpts\n+    }\n+  })\n+}\n+\n+module.exports = { createProxy }","path":"backend/src/gitlab/proxy.js","position":null,"original_position":91,"commit_id":"eaf07c2c055987022fa7fa26fb75d71d67a30609","original_commit_id":"2d0b45328c26a317b09ecba8102fa9199f4e0e14","user":{"login":"velrest","id":15276514,"node_id":"MDQ6VXNlcjE1Mjc2NTE0","avatar_url":"https://avatars0.githubusercontent.com/u/15276514?v=4","gravatar_id":"","url":"https://api.github.com/users/velrest","html_url":"https://github.com/velrest","followers_url":"https://api.github.com/users/velrest/followers","following_url":"https://api.github.com/users/velrest/following{/other_user}","gists_url":"https://api.github.com/users/velrest/gists{/gist_id}","starred_url":"https://api.github.com/users/velrest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/velrest/subscriptions","organizations_url":"https://api.github.com/users/velrest/orgs","repos_url":"https://api.github.com/users/velrest/repos","events_url":"https://api.github.com/users/velrest/events{/privacy}","received_events_url":"https://api.github.com/users/velrest/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2018-06-01T14:27:39Z","updated_at":"2018-06-01T14:27:39Z","html_url":"https://github.com/adfinis-sygroup/customer-center/pull/67#discussion_r192413401","pull_request_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/comments/192413401"},"html":{"href":"https://github.com/adfinis-sygroup/customer-center/pull/67#discussion_r192413401"},"pull_request":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67"}},"in_reply_to_id":189887968},"pull_request":{"url":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67","id":177497968,"node_id":"MDExOlB1bGxSZXF1ZXN0MTc3NDk3OTY4","html_url":"https://github.com/adfinis-sygroup/customer-center/pull/67","diff_url":"https://github.com/adfinis-sygroup/customer-center/pull/67.diff","patch_url":"https://github.com/adfinis-sygroup/customer-center/pull/67.patch","issue_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/issues/67","number":67,"state":"open","locked":false,"title":"IPA: Gitlab integration","user":{"login":"velrest","id":15276514,"node_id":"MDQ6VXNlcjE1Mjc2NTE0","avatar_url":"https://avatars0.githubusercontent.com/u/15276514?v=4","gravatar_id":"","url":"https://api.github.com/users/velrest","html_url":"https://github.com/velrest","followers_url":"https://api.github.com/users/velrest/followers","following_url":"https://api.github.com/users/velrest/following{/other_user}","gists_url":"https://api.github.com/users/velrest/gists{/gist_id}","starred_url":"https://api.github.com/users/velrest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/velrest/subscriptions","organizations_url":"https://api.github.com/users/velrest/orgs","repos_url":"https://api.github.com/users/velrest/repos","events_url":"https://api.github.com/users/velrest/events{/privacy}","received_events_url":"https://api.github.com/users/velrest/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-26T16:19:37Z","updated_at":"2018-06-01T14:27:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"48472cb310eea8769b06deb8fc7f62e79802f152","assignee":{"login":"anehx","id":6150577,"node_id":"MDQ6VXNlcjYxNTA1Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/6150577?v=4","gravatar_id":"","url":"https://api.github.com/users/anehx","html_url":"https://github.com/anehx","followers_url":"https://api.github.com/users/anehx/followers","following_url":"https://api.github.com/users/anehx/following{/other_user}","gists_url":"https://api.github.com/users/anehx/gists{/gist_id}","starred_url":"https://api.github.com/users/anehx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anehx/subscriptions","organizations_url":"https://api.github.com/users/anehx/orgs","repos_url":"https://api.github.com/users/anehx/repos","events_url":"https://api.github.com/users/anehx/events{/privacy}","received_events_url":"https://api.github.com/users/anehx/received_events","type":"User","site_admin":false},"assignees":[{"login":"anehx","id":6150577,"node_id":"MDQ6VXNlcjYxNTA1Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/6150577?v=4","gravatar_id":"","url":"https://api.github.com/users/anehx","html_url":"https://github.com/anehx","followers_url":"https://api.github.com/users/anehx/followers","following_url":"https://api.github.com/users/anehx/following{/other_user}","gists_url":"https://api.github.com/users/anehx/gists{/gist_id}","starred_url":"https://api.github.com/users/anehx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anehx/subscriptions","organizations_url":"https://api.github.com/users/anehx/orgs","repos_url":"https://api.github.com/users/anehx/repos","events_url":"https://api.github.com/users/anehx/events{/privacy}","received_events_url":"https://api.github.com/users/anehx/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67/commits","review_comments_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67/comments","review_comment_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/issues/67/comments","statuses_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/statuses/eaf07c2c055987022fa7fa26fb75d71d67a30609","head":{"label":"velrest:gitlab_integration","ref":"gitlab_integration","sha":"eaf07c2c055987022fa7fa26fb75d71d67a30609","user":{"login":"velrest","id":15276514,"node_id":"MDQ6VXNlcjE1Mjc2NTE0","avatar_url":"https://avatars0.githubusercontent.com/u/15276514?v=4","gravatar_id":"","url":"https://api.github.com/users/velrest","html_url":"https://github.com/velrest","followers_url":"https://api.github.com/users/velrest/followers","following_url":"https://api.github.com/users/velrest/following{/other_user}","gists_url":"https://api.github.com/users/velrest/gists{/gist_id}","starred_url":"https://api.github.com/users/velrest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/velrest/subscriptions","organizations_url":"https://api.github.com/users/velrest/orgs","repos_url":"https://api.github.com/users/velrest/repos","events_url":"https://api.github.com/users/velrest/events{/privacy}","received_events_url":"https://api.github.com/users/velrest/received_events","type":"User","site_admin":false},"repo":{"id":110116671,"node_id":"MDEwOlJlcG9zaXRvcnkxMTAxMTY2NzE=","name":"customer-center","full_name":"velrest/customer-center","owner":{"login":"velrest","id":15276514,"node_id":"MDQ6VXNlcjE1Mjc2NTE0","avatar_url":"https://avatars0.githubusercontent.com/u/15276514?v=4","gravatar_id":"","url":"https://api.github.com/users/velrest","html_url":"https://github.com/velrest","followers_url":"https://api.github.com/users/velrest/followers","following_url":"https://api.github.com/users/velrest/following{/other_user}","gists_url":"https://api.github.com/users/velrest/gists{/gist_id}","starred_url":"https://api.github.com/users/velrest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/velrest/subscriptions","organizations_url":"https://api.github.com/users/velrest/orgs","repos_url":"https://api.github.com/users/velrest/repos","events_url":"https://api.github.com/users/velrest/events{/privacy}","received_events_url":"https://api.github.com/users/velrest/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/velrest/customer-center","description":"Adfinis SyGroup AG - Customer Center","fork":true,"url":"https://api.github.com/repos/velrest/customer-center","forks_url":"https://api.github.com/repos/velrest/customer-center/forks","keys_url":"https://api.github.com/repos/velrest/customer-center/keys{/key_id}","collaborators_url":"https://api.github.com/repos/velrest/customer-center/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/velrest/customer-center/teams","hooks_url":"https://api.github.com/repos/velrest/customer-center/hooks","issue_events_url":"https://api.github.com/repos/velrest/customer-center/issues/events{/number}","events_url":"https://api.github.com/repos/velrest/customer-center/events","assignees_url":"https://api.github.com/repos/velrest/customer-center/assignees{/user}","branches_url":"https://api.github.com/repos/velrest/customer-center/branches{/branch}","tags_url":"https://api.github.com/repos/velrest/customer-center/tags","blobs_url":"https://api.github.com/repos/velrest/customer-center/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/velrest/customer-center/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/velrest/customer-center/git/refs{/sha}","trees_url":"https://api.github.com/repos/velrest/customer-center/git/trees{/sha}","statuses_url":"https://api.github.com/repos/velrest/customer-center/statuses/{sha}","languages_url":"https://api.github.com/repos/velrest/customer-center/languages","stargazers_url":"https://api.github.com/repos/velrest/customer-center/stargazers","contributors_url":"https://api.github.com/repos/velrest/customer-center/contributors","subscribers_url":"https://api.github.com/repos/velrest/customer-center/subscribers","subscription_url":"https://api.github.com/repos/velrest/customer-center/subscription","commits_url":"https://api.github.com/repos/velrest/customer-center/commits{/sha}","git_commits_url":"https://api.github.com/repos/velrest/customer-center/git/commits{/sha}","comments_url":"https://api.github.com/repos/velrest/customer-center/comments{/number}","issue_comment_url":"https://api.github.com/repos/velrest/customer-center/issues/comments{/number}","contents_url":"https://api.github.com/repos/velrest/customer-center/contents/{+path}","compare_url":"https://api.github.com/repos/velrest/customer-center/compare/{base}...{head}","merges_url":"https://api.github.com/repos/velrest/customer-center/merges","archive_url":"https://api.github.com/repos/velrest/customer-center/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/velrest/customer-center/downloads","issues_url":"https://api.github.com/repos/velrest/customer-center/issues{/number}","pulls_url":"https://api.github.com/repos/velrest/customer-center/pulls{/number}","milestones_url":"https://api.github.com/repos/velrest/customer-center/milestones{/number}","notifications_url":"https://api.github.com/repos/velrest/customer-center/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/velrest/customer-center/labels{/name}","releases_url":"https://api.github.com/repos/velrest/customer-center/releases{/id}","deployments_url":"https://api.github.com/repos/velrest/customer-center/deployments","created_at":"2017-11-09T13:08:53Z","updated_at":"2018-05-15T10:35:50Z","pushed_at":"2018-06-01T14:26:57Z","git_url":"git://github.com/velrest/customer-center.git","ssh_url":"git@github.com:velrest/customer-center.git","clone_url":"https://github.com/velrest/customer-center.git","svn_url":"https://github.com/velrest/customer-center","homepage":null,"size":1471,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"adfinis-sygroup:master","ref":"master","sha":"626599ce725aec159ddae3eb956a48a4a94d8617","user":{"login":"adfinis-sygroup","id":1175860,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzU4NjA=","avatar_url":"https://avatars2.githubusercontent.com/u/1175860?v=4","gravatar_id":"","url":"https://api.github.com/users/adfinis-sygroup","html_url":"https://github.com/adfinis-sygroup","followers_url":"https://api.github.com/users/adfinis-sygroup/followers","following_url":"https://api.github.com/users/adfinis-sygroup/following{/other_user}","gists_url":"https://api.github.com/users/adfinis-sygroup/gists{/gist_id}","starred_url":"https://api.github.com/users/adfinis-sygroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adfinis-sygroup/subscriptions","organizations_url":"https://api.github.com/users/adfinis-sygroup/orgs","repos_url":"https://api.github.com/users/adfinis-sygroup/repos","events_url":"https://api.github.com/users/adfinis-sygroup/events{/privacy}","received_events_url":"https://api.github.com/users/adfinis-sygroup/received_events","type":"Organization","site_admin":false},"repo":{"id":38248604,"node_id":"MDEwOlJlcG9zaXRvcnkzODI0ODYwNA==","name":"customer-center","full_name":"adfinis-sygroup/customer-center","owner":{"login":"adfinis-sygroup","id":1175860,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzU4NjA=","avatar_url":"https://avatars2.githubusercontent.com/u/1175860?v=4","gravatar_id":"","url":"https://api.github.com/users/adfinis-sygroup","html_url":"https://github.com/adfinis-sygroup","followers_url":"https://api.github.com/users/adfinis-sygroup/followers","following_url":"https://api.github.com/users/adfinis-sygroup/following{/other_user}","gists_url":"https://api.github.com/users/adfinis-sygroup/gists{/gist_id}","starred_url":"https://api.github.com/users/adfinis-sygroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adfinis-sygroup/subscriptions","organizations_url":"https://api.github.com/users/adfinis-sygroup/orgs","repos_url":"https://api.github.com/users/adfinis-sygroup/repos","events_url":"https://api.github.com/users/adfinis-sygroup/events{/privacy}","received_events_url":"https://api.github.com/users/adfinis-sygroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adfinis-sygroup/customer-center","description":"Adfinis SyGroup AG - Customer Center","fork":false,"url":"https://api.github.com/repos/adfinis-sygroup/customer-center","forks_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/forks","keys_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/teams","hooks_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/hooks","issue_events_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/issues/events{/number}","events_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/events","assignees_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/assignees{/user}","branches_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/branches{/branch}","tags_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/tags","blobs_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/git/refs{/sha}","trees_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/statuses/{sha}","languages_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/languages","stargazers_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/stargazers","contributors_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/contributors","subscribers_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/subscribers","subscription_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/subscription","commits_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/commits{/sha}","git_commits_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/git/commits{/sha}","comments_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/comments{/number}","issue_comment_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/issues/comments{/number}","contents_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/contents/{+path}","compare_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/merges","archive_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/downloads","issues_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/issues{/number}","pulls_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls{/number}","milestones_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/milestones{/number}","notifications_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/labels{/name}","releases_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/releases{/id}","deployments_url":"https://api.github.com/repos/adfinis-sygroup/customer-center/deployments","created_at":"2015-06-29T13:17:30Z","updated_at":"2018-05-15T10:28:19Z","pushed_at":"2018-06-01T14:26:58Z","git_url":"git://github.com/adfinis-sygroup/customer-center.git","ssh_url":"git@github.com:adfinis-sygroup/customer-center.git","clone_url":"https://github.com/adfinis-sygroup/customer-center.git","svn_url":"https://github.com/adfinis-sygroup/customer-center","homepage":null,"size":1366,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":7,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67"},"html":{"href":"https://github.com/adfinis-sygroup/customer-center/pull/67"},"issue":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/issues/67"},"comments":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/adfinis-sygroup/customer-center/statuses/eaf07c2c055987022fa7fa26fb75d71d67a30609"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"velrest"}}