Skip to content

Commit

Permalink
Merge PR #482 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by thomaspaulb
  • Loading branch information
OCA-git-bot committed Oct 10, 2023
2 parents 2d92583 + 9297292 commit 8d18d8f
Show file tree
Hide file tree
Showing 101 changed files with 25,826 additions and 0 deletions.
131 changes: 131 additions & 0 deletions password_security/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
=================
Password Security
=================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
:target: https://github.com/OCA/server-auth/tree/15.0/password_security
:alt: OCA/server-auth
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-auth-15-0/server-auth-15-0-password_security
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/251/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows admin to set company-level password security requirements
and enforces them on the user.

It contains features such as

* Password expiration days
* Password length requirement
* Password minimum number of lowercase letters
* Password minimum number of uppercase letters
* Password minimum number of numbers
* Password minimum number of special characters

**Table of contents**

.. contents::
:local:

Configuration
=============

Navigate to General Settings under Configuration
Scroll down to the ``Password Policy`` section
Set the policies to your liking.

Password complexity requirements will be enforced upon next password change for
any user in that company.

**Settings & Defaults**

These are defined at the company level:

===================== ======= ===================================================
Name Default Description
===================== ======= ===================================================
password_expiration 60 Days until passwords expire
password_length 12 Minimum number of characters in password
password_lower 0 Minimum number of lowercase letter in password
password_upper 0 Minimum number of uppercase letters in password
password_numeric 0 Minimum number of number in password
password_special 0 Minimum number of unique special character in password
password_history 30 Disallow reuse of this many previous passwords
password_minimum 24 Amount of hours that must pass until another reset
===================== ======= ===================================================

Usage
=====

Configure using above instructions for each company that should have password
security mandates.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/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 <https://github.com/OCA/server-auth/issues/new?body=module:%20password_security%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* LasLabs
* Kaushal Prajapati
* Tecnativa
* initOS GmbH
* Omar Nasr

Contributors
~~~~~~~~~~~~

* James Foster <jfoster@laslabs.com>
* Dave Lasley <dave@laslabs.com>
* Kaushal Prajapati <kbprajapati@live.com>
* Petar Najman <petar.najman@modoolar.com>
* Shepilov Vladislav <shepilov.v@protonmail.com>
* Florian Kantelberg <florian.kantelberg@initos.com>
* Dhara Solanki <dhara.solanki@initos.com>

* `Open Source Integrators <https://opensourceintegrators.com>`_

* Chandresh Thakkar <cthakkar@opensourceintegrators.com>
* Daniel Reis <dreis@opensourceintegrators.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/15.0/password_security>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions password_security/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2015 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import controllers, models
32 changes: 32 additions & 0 deletions password_security/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2015 LasLabs Inc.
# Copyright 2018 Modoolar <info@modoolar.com>.
# Copyright 2019 initOS GmbH
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Password Security",
"summary": "Allow admin to set password security requirements.",
"version": "16.0.1.0.0",
"author": "LasLabs, "
"Onestein, "
"Kaushal Prajapati, "
"Tecnativa, "
"initOS GmbH, "
"Omar Nasr, "
"Odoo Community Association (OCA)",
"category": "Base",
"depends": [
"auth_signup",
"auth_password_policy_signup",
],
"website": "https://github.com/OCA/server-auth",
"license": "LGPL-3",
"data": [
"views/res_config_settings_views.xml",
"security/ir.model.access.csv",
"security/res_users_pass_history.xml",
],
"demo": [
"demo/res_users.xml",
],
"installable": True,
}
4 changes: 4 additions & 0 deletions password_security/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2015 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import main
61 changes: 61 additions & 0 deletions password_security/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2015 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

import logging

from werkzeug.exceptions import BadRequest

from odoo import http
from odoo.http import request

from odoo.addons.auth_signup.controllers.main import AuthSignupHome
from odoo.addons.web.controllers.home import ensure_db

_logger = logging.getLogger(__name__)


class PasswordSecurityHome(AuthSignupHome):
def do_signup(self, qcontext):
password = qcontext.get("password")
user = request.env.user
user._check_password(password)
return super(PasswordSecurityHome, self).do_signup(qcontext)

@http.route()
def web_login(self, *args, **kw):
ensure_db()
response = super(PasswordSecurityHome, self).web_login(*args, **kw)
if not request.params.get("login_success"):
return response
if not request.env.user:
return response
# Now, I'm an authenticated user
if not request.env.user._password_has_expired():
return response
# My password is expired, kick me out
request.env.user.action_expire_password()
request.session.logout(keep_db=True)
# I was kicked out, so set login_success in request params to False
request.params["login_success"] = False
redirect = request.env.user.partner_id.signup_url
return request.redirect(redirect)

@http.route()
def web_auth_signup(self, *args, **kw):
"""Try to catch all the possible exceptions not already handled in the parent method"""

try:
qcontext = self.get_auth_signup_qcontext()
except Exception:
raise BadRequest from None # HTTPError: 400 Client Error: BAD REQUEST

try:
return super(PasswordSecurityHome, self).web_auth_signup(*args, **kw)
except Exception as e:
# Here we catch any generic exception since UserError is already
# handled in parent method web_auth_signup()
qcontext["error"] = str(e)
response = request.render("auth_signup.signup", qcontext)
response.headers["X-Frame-Options"] = "SAMEORIGIN"
response.headers["Content-Security-Policy"] = "frame-ancestors 'self'"
return response
9 changes: 9 additions & 0 deletions password_security/demo/res_users.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!--
Copyright 2016 LasLabs Inc.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->
<odoo>
<record id="base.user_root" model="res.users">
<field name="password_write_date" eval="datetime.now()" />
</record>
</odoo>
Loading

0 comments on commit 8d18d8f

Please sign in to comment.