{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/server-tools/pulls/comments/114865350","pull_request_review_id":36361161,"id":114865350,"diff_hunk":"@@ -0,0 +1,104 @@\n+# -*- encoding: utf-8 -*-\n+##############################################################################\n+#\n+#    Tracks Authentication Attempts and Prevents Brute-force Attacks module\n+#    Copyright (C) 2015-Today GRAP (http://www.grap.coop)\n+#    @author Sylvain LE GAL (https://twitter.com/legalsylvain)\n+#\n+#    This program is free software: you can redistribute it and/or modify\n+#    it under the terms of the GNU Affero General Public License as\n+#    published by the Free Software Foundation, either version 3 of the\n+#    License, or (at your option) any later version.\n+#\n+#    This program is distributed in the hope that it will be useful,\n+#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+#    GNU Affero General Public License for more details.\n+#\n+#    You should have received a copy of the GNU Affero General Public License\n+#    along with this program. If not, see <http://www.gnu.org/licenses/>.\n+#\n+##############################################################################\n+\n+import logging\n+\n+from openerp import fields, http, registry, SUPERUSER_ID\n+from openerp.http import request\n+from openerp.addons.web.controllers.main import Home, ensure_db\n+\n+_logger = logging.getLogger(__name__)\n+\n+\n+class LoginController(Home):\n+    @http.route()\n+    def web_login(self, redirect=None, **kw):\n+        if request.httprequest.method == 'POST':\n+            ensure_db()\n+            remote = request.httprequest.remote_addr\n+            # Get registry and cursor\n+            config_obj = registry(request.session.db)['ir.config_parameter']\n+            attempt_obj = registry(\n+                request.session.db)['res.authentication.attempt']\n+            banned_remote_obj = registry(\n+                request.session.db)['res.banned.remote']\n+            cursor = attempt_obj.pool.cursor()\n+\n+            # Get Settings\n+            max_attempts_qty = int(config_obj.search_read(\n+                cursor, SUPERUSER_ID,\n+                [('key', '=', 'auth_brute_force.max_attempt_qty')],\n+                ['value'])[0]['value'])\n+\n+            # Test if remote user is banned\n+            banned = banned_remote_obj.search(cursor, SUPERUSER_ID, [","path":"auth_brute_force/controllers/controllers.py","position":53,"original_position":53,"commit_id":"43317c565bdf047aa13cba8e7bc7d6dcab8d6581","original_commit_id":"43317c565bdf047aa13cba8e7bc7d6dcab8d6581","user":{"login":"lasley","id":7397578,"avatar_url":"https://avatars0.githubusercontent.com/u/7397578?v=3","gravatar_id":"","url":"https://api.github.com/users/lasley","html_url":"https://github.com/lasley","followers_url":"https://api.github.com/users/lasley/followers","following_url":"https://api.github.com/users/lasley/following{/other_user}","gists_url":"https://api.github.com/users/lasley/gists{/gist_id}","starred_url":"https://api.github.com/users/lasley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasley/subscriptions","organizations_url":"https://api.github.com/users/lasley/orgs","repos_url":"https://api.github.com/users/lasley/repos","events_url":"https://api.github.com/users/lasley/events{/privacy}","received_events_url":"https://api.github.com/users/lasley/received_events","type":"User","site_admin":false},"body":"Old api","created_at":"2017-05-04T19:17:46Z","updated_at":"2017-05-04T19:25:58Z","html_url":"https://github.com/OCA/server-tools/pull/663#discussion_r114865350","pull_request_url":"https://api.github.com/repos/OCA/server-tools/pulls/663","_links":{"self":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/comments/114865350"},"html":{"href":"https://github.com/OCA/server-tools/pull/663#discussion_r114865350"},"pull_request":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/663"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/server-tools/pulls/663","id":98956729,"html_url":"https://github.com/OCA/server-tools/pull/663","diff_url":"https://github.com/OCA/server-tools/pull/663.diff","patch_url":"https://github.com/OCA/server-tools/pull/663.patch","issue_url":"https://api.github.com/repos/OCA/server-tools/issues/663","number":663,"state":"open","locked":false,"title":"[9.0] MIG auth_brute_force","user":{"login":"nicomacr","id":7657373,"avatar_url":"https://avatars3.githubusercontent.com/u/7657373?v=3","gravatar_id":"","url":"https://api.github.com/users/nicomacr","html_url":"https://github.com/nicomacr","followers_url":"https://api.github.com/users/nicomacr/followers","following_url":"https://api.github.com/users/nicomacr/following{/other_user}","gists_url":"https://api.github.com/users/nicomacr/gists{/gist_id}","starred_url":"https://api.github.com/users/nicomacr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicomacr/subscriptions","organizations_url":"https://api.github.com/users/nicomacr/orgs","repos_url":"https://api.github.com/users/nicomacr/repos","events_url":"https://api.github.com/users/nicomacr/events{/privacy}","received_events_url":"https://api.github.com/users/nicomacr/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-21T15:53:29Z","updated_at":"2017-05-04T19:25:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee6f3b3297348dad3363004ad765b1742b422478","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/OCA/server-tools/milestones/4","html_url":"https://github.com/OCA/server-tools/milestone/4","labels_url":"https://api.github.com/repos/OCA/server-tools/milestones/4/labels","id":1354400,"number":4,"title":"9.0","description":null,"creator":{"login":"pedrobaeza","id":7165771,"avatar_url":"https://avatars1.githubusercontent.com/u/7165771?v=3","gravatar_id":"","url":"https://api.github.com/users/pedrobaeza","html_url":"https://github.com/pedrobaeza","followers_url":"https://api.github.com/users/pedrobaeza/followers","following_url":"https://api.github.com/users/pedrobaeza/following{/other_user}","gists_url":"https://api.github.com/users/pedrobaeza/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrobaeza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrobaeza/subscriptions","organizations_url":"https://api.github.com/users/pedrobaeza/orgs","repos_url":"https://api.github.com/users/pedrobaeza/repos","events_url":"https://api.github.com/users/pedrobaeza/events{/privacy}","received_events_url":"https://api.github.com/users/pedrobaeza/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":68,"state":"open","created_at":"2015-10-14T00:54:02Z","updated_at":"2017-05-04T19:11:42Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/OCA/server-tools/pulls/663/commits","review_comments_url":"https://api.github.com/repos/OCA/server-tools/pulls/663/comments","review_comment_url":"https://api.github.com/repos/OCA/server-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/server-tools/issues/663/comments","statuses_url":"https://api.github.com/repos/OCA/server-tools/statuses/43317c565bdf047aa13cba8e7bc7d6dcab8d6581","head":{"label":"adhoc-dev:9.0_mig_auth_brute_force","ref":"9.0_mig_auth_brute_force","sha":"43317c565bdf047aa13cba8e7bc7d6dcab8d6581","user":{"login":"adhoc-dev","id":10548663,"avatar_url":"https://avatars2.githubusercontent.com/u/10548663?v=3","gravatar_id":"","url":"https://api.github.com/users/adhoc-dev","html_url":"https://github.com/adhoc-dev","followers_url":"https://api.github.com/users/adhoc-dev/followers","following_url":"https://api.github.com/users/adhoc-dev/following{/other_user}","gists_url":"https://api.github.com/users/adhoc-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/adhoc-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adhoc-dev/subscriptions","organizations_url":"https://api.github.com/users/adhoc-dev/orgs","repos_url":"https://api.github.com/users/adhoc-dev/repos","events_url":"https://api.github.com/users/adhoc-dev/events{/privacy}","received_events_url":"https://api.github.com/users/adhoc-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":74677142,"name":"server-tools","full_name":"adhoc-dev/server-tools","owner":{"login":"adhoc-dev","id":10548663,"avatar_url":"https://avatars2.githubusercontent.com/u/10548663?v=3","gravatar_id":"","url":"https://api.github.com/users/adhoc-dev","html_url":"https://github.com/adhoc-dev","followers_url":"https://api.github.com/users/adhoc-dev/followers","following_url":"https://api.github.com/users/adhoc-dev/following{/other_user}","gists_url":"https://api.github.com/users/adhoc-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/adhoc-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adhoc-dev/subscriptions","organizations_url":"https://api.github.com/users/adhoc-dev/orgs","repos_url":"https://api.github.com/users/adhoc-dev/repos","events_url":"https://api.github.com/users/adhoc-dev/events{/privacy}","received_events_url":"https://api.github.com/users/adhoc-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adhoc-dev/server-tools","description":"Tools for Odoo Administrators to improve some technical features on Odoo.","fork":true,"url":"https://api.github.com/repos/adhoc-dev/server-tools","forks_url":"https://api.github.com/repos/adhoc-dev/server-tools/forks","keys_url":"https://api.github.com/repos/adhoc-dev/server-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adhoc-dev/server-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adhoc-dev/server-tools/teams","hooks_url":"https://api.github.com/repos/adhoc-dev/server-tools/hooks","issue_events_url":"https://api.github.com/repos/adhoc-dev/server-tools/issues/events{/number}","events_url":"https://api.github.com/repos/adhoc-dev/server-tools/events","assignees_url":"https://api.github.com/repos/adhoc-dev/server-tools/assignees{/user}","branches_url":"https://api.github.com/repos/adhoc-dev/server-tools/branches{/branch}","tags_url":"https://api.github.com/repos/adhoc-dev/server-tools/tags","blobs_url":"https://api.github.com/repos/adhoc-dev/server-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adhoc-dev/server-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adhoc-dev/server-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/adhoc-dev/server-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adhoc-dev/server-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/adhoc-dev/server-tools/languages","stargazers_url":"https://api.github.com/repos/adhoc-dev/server-tools/stargazers","contributors_url":"https://api.github.com/repos/adhoc-dev/server-tools/contributors","subscribers_url":"https://api.github.com/repos/adhoc-dev/server-tools/subscribers","subscription_url":"https://api.github.com/repos/adhoc-dev/server-tools/subscription","commits_url":"https://api.github.com/repos/adhoc-dev/server-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/adhoc-dev/server-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/adhoc-dev/server-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/adhoc-dev/server-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/adhoc-dev/server-tools/contents/{+path}","compare_url":"https://api.github.com/repos/adhoc-dev/server-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adhoc-dev/server-tools/merges","archive_url":"https://api.github.com/repos/adhoc-dev/server-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adhoc-dev/server-tools/downloads","issues_url":"https://api.github.com/repos/adhoc-dev/server-tools/issues{/number}","pulls_url":"https://api.github.com/repos/adhoc-dev/server-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/adhoc-dev/server-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/adhoc-dev/server-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adhoc-dev/server-tools/labels{/name}","releases_url":"https://api.github.com/repos/adhoc-dev/server-tools/releases{/id}","deployments_url":"https://api.github.com/repos/adhoc-dev/server-tools/deployments","created_at":"2016-11-24T13:46:34Z","updated_at":"2016-11-24T13:46:37Z","pushed_at":"2017-02-14T14:43:25Z","git_url":"git://github.com/adhoc-dev/server-tools.git","ssh_url":"git@github.com:adhoc-dev/server-tools.git","clone_url":"https://github.com/adhoc-dev/server-tools.git","svn_url":"https://github.com/adhoc-dev/server-tools","homepage":"https://odoo-community.org/project/tools-maintainers-30","size":9307,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"10.0"}},"base":{"label":"OCA:9.0","ref":"9.0","sha":"bbb6e3a4d07d24049310100e001df76b07c5376c","user":{"login":"OCA","id":7600578,"avatar_url":"https://avatars2.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"repo":{"id":20896532,"name":"server-tools","full_name":"OCA/server-tools","owner":{"login":"OCA","id":7600578,"avatar_url":"https://avatars2.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OCA/server-tools","description":"Tools for Odoo Administrators to improve some technical features on Odoo.","fork":false,"url":"https://api.github.com/repos/OCA/server-tools","forks_url":"https://api.github.com/repos/OCA/server-tools/forks","keys_url":"https://api.github.com/repos/OCA/server-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/server-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/server-tools/teams","hooks_url":"https://api.github.com/repos/OCA/server-tools/hooks","issue_events_url":"https://api.github.com/repos/OCA/server-tools/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/server-tools/events","assignees_url":"https://api.github.com/repos/OCA/server-tools/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/server-tools/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/server-tools/tags","blobs_url":"https://api.github.com/repos/OCA/server-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/server-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/server-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/server-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/server-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/server-tools/languages","stargazers_url":"https://api.github.com/repos/OCA/server-tools/stargazers","contributors_url":"https://api.github.com/repos/OCA/server-tools/contributors","subscribers_url":"https://api.github.com/repos/OCA/server-tools/subscribers","subscription_url":"https://api.github.com/repos/OCA/server-tools/subscription","commits_url":"https://api.github.com/repos/OCA/server-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/server-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/server-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/server-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/server-tools/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/server-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/server-tools/merges","archive_url":"https://api.github.com/repos/OCA/server-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/server-tools/downloads","issues_url":"https://api.github.com/repos/OCA/server-tools/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/server-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/server-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/server-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/server-tools/labels{/name}","releases_url":"https://api.github.com/repos/OCA/server-tools/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/server-tools/deployments","created_at":"2014-06-16T18:52:44Z","updated_at":"2017-05-03T10:33:55Z","pushed_at":"2017-05-03T17:06:13Z","git_url":"git://github.com/OCA/server-tools.git","ssh_url":"git@github.com:OCA/server-tools.git","clone_url":"https://github.com/OCA/server-tools.git","svn_url":"https://github.com/OCA/server-tools","homepage":"https://odoo-community.org/project/tools-maintainers-30","size":12540,"stargazers_count":175,"watchers_count":175,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":490,"mirror_url":null,"open_issues_count":161,"forks":490,"open_issues":161,"watchers":175,"default_branch":"10.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/663"},"html":{"href":"https://github.com/OCA/server-tools/pull/663"},"issue":{"href":"https://api.github.com/repos/OCA/server-tools/issues/663"},"comments":{"href":"https://api.github.com/repos/OCA/server-tools/issues/663/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/663/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/663/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/server-tools/statuses/43317c565bdf047aa13cba8e7bc7d6dcab8d6581"}}}}
{"actor":{"display_login":"lasley"}}