Browse Source

Merge f8cfa10c4f into dff1d64a13

pull/402/merge
Dave Lasley 5 years ago
committed by GitHub
parent
commit
312d4dcc2e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 50
      web_session_allow_public/README.rst
  2. 5
      web_session_allow_public/__init__.py
  3. 17
      web_session_allow_public/__openerp__.py
  4. 5
      web_session_allow_public/models/__init__.py
  5. 17
      web_session_allow_public/models/ir_http.py
  6. 5
      web_session_allow_public/tests/__init__.py
  7. 25
      web_session_allow_public/tests/test_ir_http.py

50
web_session_allow_public/README.rst

@ -0,0 +1,50 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
=========================
Allow Public RPC Sessions
=========================
This module allows for RPC calls from a public user.
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/9.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Dave Lasley <dave@laslabs.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

5
web_session_allow_public/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import models

17
web_session_allow_public/__openerp__.py

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Allow Public RPC Sessions",
"version": "9.0.1.0.0",
"category": "Website",
"website": "https://laslabs.com/",
"author": "LasLabs, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": [
"base",
],
}

5
web_session_allow_public/models/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import ir_http

17
web_session_allow_public/models/ir_http.py

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from openerp import models
from openerp.http import SessionExpiredException
class IrHttp(models.Model):
_inherit = 'ir.http'
def _auth_method_user(self):
try:
return super(IrHttp, self)._auth_method_user()
except SessionExpiredException:
return self._auth_method_public()

5
web_session_allow_public/tests/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import test_ir_http

25
web_session_allow_public/tests/test_ir_http.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
import mock
from openerp.tests.common import HttpCase
from openerp.addons.base.ir.ir_http import ir_http
MODULE_PATH = 'openerp.addons.base.ir.ir_http'
class TestIrHttp(HttpCase):
@mock.patch('%s.request' % MODULE_PATH)
def test_public_session(self, request):
""" It should allow HTTP authentication on public user """
request.session.uid = False
with mock.patch.object(
ir_http, '_auth_method_public'
) as _auth_method_public:
res = self.env['ir.http']._auth_method_user()
self.assertEqual(res, _auth_method_public())
Loading…
Cancel
Save