Skip to main content

Authenticate via HTTP Remote User

Project description

License: AGPL-3

Authentication From HTTP Remote User

This module initialize the session by looking for the field HTTP_REMOTE_USER in the HEADERS of the HTTP request and trying to bind the given value to a user. To be active, the module must be installed in the expected databases and loaded at startup; Add the –load parameter to the startup command:

--load=web,auth_from_http_remote_user, ...

If the field is found in the header and no user matches the given one, the system issue a login error page. (401 Unauthorized)

Configuration

The module allows integration with external security systems [1] that can pass along authentication of a user via Remote_User HTTP header field. In many cases, this is achieved via server like Apache HTTPD or nginx proxying Odoo.

How to test the module with Apache [2]

Apache can be used as a reverse proxy providing the authentication and adding the required field in the Http headers.

Install apache:

$ sudo apt-get install apache2

Define a new vhost to Apache by putting a new file in /etc/apache2/sites-available:

$ sudo vi  /etc/apache2/sites-available/MY_VHOST.com

with the following content:

<VirtualHost *:80>
  ServerName MY_VHOST.com
  ProxyRequests Off
  <Location />
    AuthType Basic
    AuthName "Test Odoo auth_from_http_remote_user"
    AuthBasicProvider file
    AuthUserFile /etc/apache2/MY_VHOST.htpasswd
    Require valid-user

    RewriteEngine On
    RewriteCond %{LA-U:REMOTE_USER} (.+)
    RewriteRule . - [E=RU:%1]
    RequestHeader set Remote-User "%{RU}e" env=RU
  </Location>

  RequestHeader unset Remote-User early
  ProxyPass / http://127.0.0.1:8069/  retry=10
  ProxyPassReverse  / http://127.0.0.1:8069/
  ProxyPreserveHost On
</VirtualHost>

Enable the required apache modules:

$ sudo a2enmod headers
$ sudo a2enmod proxy
$ sudo a2enmod rewrite
$ sudo a2enmod proxy_http

Enable your new vhost:

$ sudo a2ensite MY_VHOST.com

Create the htpassword file used by the configured basic authentication:

$ sudo htpasswd -cb /etc/apache2/MY_VHOST.htpasswd admin admin
$ sudo htpasswd -b /etc/apache2/MY_VHOST.htpasswd demo demo

For local test, add the MY_VHOST.com in your /etc/vhosts file.

Finally reload the configuration:

$ sudo service apache2 reload

Open your browser and go to MY_VHOST.com. If everything is well configured, you are prompted for a login and password outside Odoo and are automatically logged in the system.

Usage

Try me on Runbot

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing detailed and welcomed feedback.

Credits

Images

  • Odoo Community Association: Icon.

Contributors

  • Laurent Mignon

Maintainer

Odoo Community Association

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file odoo11_addon_auth_from_http_remote_user-11.0.1.0.0.99.dev6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for odoo11_addon_auth_from_http_remote_user-11.0.1.0.0.99.dev6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 40c3d7e3797023d57f5a039d55a7d72e5cd56963d1474782bcb56d4e8caef099
MD5 9c5d9013a34ae70cd230c1fa14f4ff52
BLAKE2b-256 4724ca982c1edcac5a5cbfdc82630a44061b5c84f9fbfa40c0d3600625cfb726

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page