Browse Source
If HTTP_REMOTE_USER is in the request headers and no corresponding user is found in odoo always issues Unauthorized (avoid redirect to the login page)
If HTTP_REMOTE_USER is in the request headers and no corresponding user is found in odoo always issues Unauthorized (avoid redirect to the login page)
If the uid in the session is not the same as the one from the binded HTTP_REMOTE_USER, always logout to clean up the sessionpull/34/head
7 changed files with 24 additions and 118 deletions
-
1auth_from_http_remote_user/__init__.py
-
9auth_from_http_remote_user/__openerp__.py
-
39auth_from_http_remote_user/controllers/main.py
-
2auth_from_http_remote_user/model.py
-
64auth_from_http_remote_user/res_config.py
-
9auth_from_http_remote_user/res_config_data.xml
-
18auth_from_http_remote_user/res_config_view.xml
@ -1,64 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Laurent Mignon |
|||
# Copyright 2014 'ACSONE SA/NV' |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from openerp.osv import orm, fields |
|||
from openerp.tools.safe_eval import safe_eval |
|||
|
|||
|
|||
class auth_from_http_remote_user_configuration(orm.TransientModel): |
|||
_inherit = 'base.config.settings' |
|||
|
|||
_columns = { |
|||
'default_login_page_disabled': fields.boolean("Disable login page when " |
|||
"login with HTTP Remote " |
|||
"User", |
|||
help=""" |
|||
Disable the default login page. |
|||
If the HTTP_REMOTE_HEADER field is not found or no user matches the given one, |
|||
the system will display a login error page if the login page is disabled. |
|||
Otherwise the normal login page will be displayed. |
|||
"""), |
|||
} |
|||
|
|||
def is_default_login_page_disabled(self, cr, uid, fields, context=None): |
|||
vals = self.get_default_default_login_page_disabled(cr, |
|||
uid, |
|||
fields, |
|||
context=context) |
|||
return vals.get('default_login_page_disabled', False) |
|||
|
|||
def get_default_default_login_page_disabled(self, cr, uid, fields, |
|||
context=None): |
|||
icp = self.pool.get('ir.config_parameter') |
|||
# we use safe_eval on the result, since the value of |
|||
# the parameter is a nonempty string |
|||
is_disabled = icp.get_param(cr, uid, 'default_login_page_disabled', |
|||
'False') |
|||
return {'default_login_page_disabled': safe_eval(is_disabled)} |
|||
|
|||
def set_default_default_login_page_disabled(self, cr, uid, ids, |
|||
context=None): |
|||
config = self.browse(cr, uid, ids[0], context=context) |
|||
icp = self.pool.get('ir.config_parameter') |
|||
# we store the repr of the value, since the value of the parameter |
|||
# is a required string |
|||
icp.set_param(cr, uid, 'default_login_page_disabled', |
|||
repr(config.default_login_page_disabled)) |
@ -1,9 +0,0 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data noupdate="1"> |
|||
<record model="ir.config_parameter" id="auth_from_http_remote_user.default_login_page_disabled"> |
|||
<field name="key">auth_from_http_remote_user.default_login_page_disabled</field> |
|||
<field name="value">False</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -1,18 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
<record id="view_general_configuration" model="ir.ui.view"> |
|||
<field name="name">base.config.settings.auth_from_http_remote_user</field> |
|||
<field name="model">base.config.settings</field> |
|||
<field name="inherit_id" ref="base_setup.view_general_configuration" /> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='module_auth_oauth']/.." position="after"> |
|||
<div> |
|||
<field name="default_login_page_disabled" class="oe_inline" /> |
|||
<label for="default_login_page_disabled" /> |
|||
</div> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue