{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/web/pulls/comments/74606913","id":74606913,"diff_hunk":"@@ -0,0 +1,22 @@\n+# -*- coding: utf-8 -*-\n+# Copyright 2016 LasLabs Inc.\n+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n+\n+from openerp import models\n+\n+\n+class ResUsers(models.Model):\n+\n+    _inherit = 'res.users'\n+\n+    def check(self, db, uid, passwd):\n+        \"\"\" Catch AccessDenied error and allow public session to proceed \"\"\"\n+        if not passwd:\n+            cr = self.pool.cursor()\n+            try:\n+                is_public = self._has_group(cr, uid, 'base.group_public')","path":"web_session_allow_public/models/res_users.py","position":17,"original_position":17,"commit_id":"7bbd6ac94265baa1263e3938970914cbcdf67940","original_commit_id":"7bbd6ac94265baa1263e3938970914cbcdf67940","user":{"login":"lasley","id":7397578,"avatar_url":"https://avatars.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":"Admittedly I didn't try it. I'm pretty sure I am hitting the non-api method here though because I'm not within an api method & don't have an env yet. The core code has three methods, api.v7 api.v8 and no api.","created_at":"2016-08-12T15:08:26Z","updated_at":"2016-08-12T15:08:26Z","html_url":"https://github.com/OCA/web/pull/402#discussion_r74606913","pull_request_url":"https://api.github.com/repos/OCA/web/pulls/402","_links":{"self":{"href":"https://api.github.com/repos/OCA/web/pulls/comments/74606913"},"html":{"href":"https://github.com/OCA/web/pull/402#discussion_r74606913"},"pull_request":{"href":"https://api.github.com/repos/OCA/web/pulls/402"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/web/pulls/402","id":80837376,"html_url":"https://github.com/OCA/web/pull/402","diff_url":"https://github.com/OCA/web/pull/402.diff","patch_url":"https://github.com/OCA/web/pull/402.patch","issue_url":"https://api.github.com/repos/OCA/web/issues/402","number":402,"state":"open","locked":false,"title":"[9.0][ADD] JS DataModel Allowing Public User Sessions","user":{"login":"lasley","id":7397578,"avatar_url":"https://avatars.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":"This PR is from our excitement in #396. Please someone tag as WIP.\r\n\r\nThe intent here to break the backend sandbox with no API breakage, providing seamless use of backend Widgets in Website views.\r\n\r\nFollowing is an excerpt of relevant talking points between @Yajo and I regarding implementation tactics. Current tactic in this PR is the Controller overrides that seem to have been disproven.\r\n\r\nOur biggest struggle with breaking the backend sandbox will be the same that is noted in the website_backend_views ReadMe - lack of support for anonymous user sessions. Anon sessions are obviously a critical component in any website, but the web.DataModel and underlying JsonRPC interface do not support it.\r\n\r\nPublic user sessions are not allowed in the underlying DataModel controllers, thus yielding a Session Expired error when attempting to access resources.\r\n\r\nWe explored the possibility of creating a password for the public user, logging in with `web.Session` JS, then working off of that. This was theoretically disproven due to use session overlap in situations such as `website_sale` shopping cart. We have not tested this idea beyond theory.\r\n\r\nThe next idea was to override the DataModel controllers to allow public sessions, which is the code currently in this PR - dubbed the hammer-style approach. \r\n\r\nRegarding this approach, however - At first sight, if you log in, go to backend, open 2 browser tabs, log out in 2nd, and try to search something in 1st, Odoo dies badly, instead of showing this like it usually does:\r\n![image](https://cloud.githubusercontent.com/assets/7397578/17564184/74dd3e46-5ee7-11e6-9f98-cc05886c1bf1.png)\r\n\r\n@Yajo checked that ultimately, [initiating a session calls res.users.check](https://github.com/odoo/odoo/blob/9.0/openerp/addons/base/res/res_users.py#L498-L511). Maybe if you overload that and when there is no password, if user is public (check that by group), then succeed (else, super()), then you could simply authenticate with require(\"web.session\").session_authenticate(db, login, False) and get a working session with public user.\r\n\r\nI will be attempting the above strategy next.\r\n\r\ncc @dreispt @antespi @pedrobaeza @t3ddftw","created_at":"2016-08-10T17:48:45Z","updated_at":"2016-08-12T15:08:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b45a97a24545faeda07140a7c0e61ba7c10df01b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OCA/web/pulls/402/commits","review_comments_url":"https://api.github.com/repos/OCA/web/pulls/402/comments","review_comment_url":"https://api.github.com/repos/OCA/web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/web/issues/402/comments","statuses_url":"https://api.github.com/repos/OCA/web/statuses/7bbd6ac94265baa1263e3938970914cbcdf67940","head":{"label":"laslabs:release/9.0/public-datamodel","ref":"release/9.0/public-datamodel","sha":"7bbd6ac94265baa1263e3938970914cbcdf67940","user":{"login":"laslabs","id":13024740,"avatar_url":"https://avatars.githubusercontent.com/u/13024740?v=3","gravatar_id":"","url":"https://api.github.com/users/laslabs","html_url":"https://github.com/laslabs","followers_url":"https://api.github.com/users/laslabs/followers","following_url":"https://api.github.com/users/laslabs/following{/other_user}","gists_url":"https://api.github.com/users/laslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/laslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laslabs/subscriptions","organizations_url":"https://api.github.com/users/laslabs/orgs","repos_url":"https://api.github.com/users/laslabs/repos","events_url":"https://api.github.com/users/laslabs/events{/privacy}","received_events_url":"https://api.github.com/users/laslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":54591946,"name":"web","full_name":"laslabs/web","owner":{"login":"laslabs","id":13024740,"avatar_url":"https://avatars.githubusercontent.com/u/13024740?v=3","gravatar_id":"","url":"https://api.github.com/users/laslabs","html_url":"https://github.com/laslabs","followers_url":"https://api.github.com/users/laslabs/followers","following_url":"https://api.github.com/users/laslabs/following{/other_user}","gists_url":"https://api.github.com/users/laslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/laslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laslabs/subscriptions","organizations_url":"https://api.github.com/users/laslabs/orgs","repos_url":"https://api.github.com/users/laslabs/repos","events_url":"https://api.github.com/users/laslabs/events{/privacy}","received_events_url":"https://api.github.com/users/laslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/laslabs/web","description":"Odoo web client UI related addons","fork":true,"url":"https://api.github.com/repos/laslabs/web","forks_url":"https://api.github.com/repos/laslabs/web/forks","keys_url":"https://api.github.com/repos/laslabs/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laslabs/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laslabs/web/teams","hooks_url":"https://api.github.com/repos/laslabs/web/hooks","issue_events_url":"https://api.github.com/repos/laslabs/web/issues/events{/number}","events_url":"https://api.github.com/repos/laslabs/web/events","assignees_url":"https://api.github.com/repos/laslabs/web/assignees{/user}","branches_url":"https://api.github.com/repos/laslabs/web/branches{/branch}","tags_url":"https://api.github.com/repos/laslabs/web/tags","blobs_url":"https://api.github.com/repos/laslabs/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laslabs/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laslabs/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/laslabs/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laslabs/web/statuses/{sha}","languages_url":"https://api.github.com/repos/laslabs/web/languages","stargazers_url":"https://api.github.com/repos/laslabs/web/stargazers","contributors_url":"https://api.github.com/repos/laslabs/web/contributors","subscribers_url":"https://api.github.com/repos/laslabs/web/subscribers","subscription_url":"https://api.github.com/repos/laslabs/web/subscription","commits_url":"https://api.github.com/repos/laslabs/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/laslabs/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/laslabs/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/laslabs/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/laslabs/web/contents/{+path}","compare_url":"https://api.github.com/repos/laslabs/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laslabs/web/merges","archive_url":"https://api.github.com/repos/laslabs/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laslabs/web/downloads","issues_url":"https://api.github.com/repos/laslabs/web/issues{/number}","pulls_url":"https://api.github.com/repos/laslabs/web/pulls{/number}","milestones_url":"https://api.github.com/repos/laslabs/web/milestones{/number}","notifications_url":"https://api.github.com/repos/laslabs/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laslabs/web/labels{/name}","releases_url":"https://api.github.com/repos/laslabs/web/releases{/id}","deployments_url":"https://api.github.com/repos/laslabs/web/deployments","created_at":"2016-03-23T20:47:06Z","updated_at":"2016-08-10T00:28:30Z","pushed_at":"2016-08-12T05:38:42Z","git_url":"git://github.com/laslabs/web.git","ssh_url":"git@github.com:laslabs/web.git","clone_url":"https://github.com/laslabs/web.git","svn_url":"https://github.com/laslabs/web","homepage":"","size":8395,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"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":1,"default_branch":"9.0"}},"base":{"label":"OCA:9.0","ref":"9.0","sha":"3e895f528c9a1678f769d964c42587b1505b2e31","user":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.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":20895915,"name":"web","full_name":"OCA/web","owner":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.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/web","description":"Odoo web client UI related addons","fork":false,"url":"https://api.github.com/repos/OCA/web","forks_url":"https://api.github.com/repos/OCA/web/forks","keys_url":"https://api.github.com/repos/OCA/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/web/teams","hooks_url":"https://api.github.com/repos/OCA/web/hooks","issue_events_url":"https://api.github.com/repos/OCA/web/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/web/events","assignees_url":"https://api.github.com/repos/OCA/web/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/web/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/web/tags","blobs_url":"https://api.github.com/repos/OCA/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/web/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/web/languages","stargazers_url":"https://api.github.com/repos/OCA/web/stargazers","contributors_url":"https://api.github.com/repos/OCA/web/contributors","subscribers_url":"https://api.github.com/repos/OCA/web/subscribers","subscription_url":"https://api.github.com/repos/OCA/web/subscription","commits_url":"https://api.github.com/repos/OCA/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/web/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/web/merges","archive_url":"https://api.github.com/repos/OCA/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/web/downloads","issues_url":"https://api.github.com/repos/OCA/web/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/web/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/web/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/web/labels{/name}","releases_url":"https://api.github.com/repos/OCA/web/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/web/deployments","created_at":"2014-06-16T18:34:12Z","updated_at":"2016-08-03T22:42:40Z","pushed_at":"2016-08-12T14:50:47Z","git_url":"git://github.com/OCA/web.git","ssh_url":"git@github.com:OCA/web.git","clone_url":"https://github.com/OCA/web.git","svn_url":"https://github.com/OCA/web","homepage":"","size":15155,"stargazers_count":103,"watchers_count":103,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":302,"mirror_url":null,"open_issues_count":105,"forks":302,"open_issues":105,"watchers":103,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/web/pulls/402"},"html":{"href":"https://github.com/OCA/web/pull/402"},"issue":{"href":"https://api.github.com/repos/OCA/web/issues/402"},"comments":{"href":"https://api.github.com/repos/OCA/web/issues/402/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/web/pulls/402/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/web/pulls/402/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/web/statuses/7bbd6ac94265baa1263e3938970914cbcdf67940"}}}}
{"actor":{"display_login":"lasley"}}