Skip to content

Commit f34b37b

Browse files
committed
Merge PR #731 into 17.0
Signed-off-by bguillot
2 parents 68a5523 + 3de6b17 commit f34b37b

100 files changed

Lines changed: 24482 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

password_security/README.rst

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
=================
2+
Password Security
3+
=================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:dc29155c73a519d3732e2806f60bd11ebb31cd8c181ebd5918e4bc68080d37aa
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-auth/tree/17.0/password_security
21+
:alt: OCA/server-auth
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-password_security
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows admin to set company-level password security
32+
requirements and enforces them on the user.
33+
34+
It contains features such as
35+
36+
- Password expiration days
37+
- Password length requirement
38+
- Password minimum number of lowercase letters
39+
- Password minimum number of uppercase letters
40+
- Password minimum number of numbers
41+
- Password minimum number of special characters
42+
43+
**Table of contents**
44+
45+
.. contents::
46+
:local:
47+
48+
Configuration
49+
=============
50+
51+
Navigate to General Settings under Configuration Scroll down to the
52+
``Password Policy`` section Set the policies to your liking.
53+
54+
Password complexity requirements will be enforced upon next password
55+
change for any user in that company.
56+
57+
**Settings & Defaults**
58+
59+
These are defined at the company level:
60+
61+
[TABLE]
62+
63+
Usage
64+
=====
65+
66+
Configure using above instructions for each company that should have
67+
password security mandates.
68+
69+
Bug Tracker
70+
===========
71+
72+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
73+
In case of trouble, please check there if your issue has already been reported.
74+
If you spotted it first, help us to smash it by providing a detailed and welcomed
75+
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20password_security%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
76+
77+
Do not contact contributors directly about support or help with technical issues.
78+
79+
Credits
80+
=======
81+
82+
Authors
83+
-------
84+
85+
* LasLabs
86+
* Onestein
87+
* Kaushal Prajapati
88+
* Tecnativa
89+
* initOS GmbH
90+
* Omar Nasr
91+
92+
Contributors
93+
------------
94+
95+
- James Foster <jfoster@laslabs.com>
96+
97+
- Dave Lasley <dave@laslabs.com>
98+
99+
- Kaushal Prajapati <kbprajapati@live.com>
100+
101+
- Petar Najman <petar.najman@modoolar.com>
102+
103+
- Shepilov Vladislav <shepilov.v@protonmail.com>
104+
105+
- Florian Kantelberg <florian.kantelberg@initos.com>
106+
107+
- Dhara Solanki <dhara.solanki@initos.com>
108+
109+
- `Open Source Integrators <https://opensourceintegrators.com>`__
110+
111+
- Chandresh Thakkar <cthakkar@opensourceintegrators.com>
112+
- Daniel Reis <dreis@opensourceintegrators.com>
113+
114+
- `Onestein <https://www.onestein.nl>`__:
115+
116+
- Andrea Stirpe <a.stirpe@onestein.nl>
117+
118+
Maintainers
119+
-----------
120+
121+
This module is maintained by the OCA.
122+
123+
.. image:: https://odoo-community.org/logo.png
124+
:alt: Odoo Community Association
125+
:target: https://odoo-community.org
126+
127+
OCA, or the Odoo Community Association, is a nonprofit organization whose
128+
mission is to support the collaborative development of Odoo features and
129+
promote its widespread use.
130+
131+
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/17.0/password_security>`_ project on GitHub.
132+
133+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

password_security/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2015 LasLabs Inc.
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from .post_install import init_config_parameters
5+
from . import controllers, models

password_security/__manifest__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2015 LasLabs Inc.
2+
# Copyright 2018 Modoolar <info@modoolar.com>.
3+
# Copyright 2019 initOS GmbH
4+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
5+
{
6+
"name": "Password Security",
7+
"summary": "Allow admin to set password security requirements.",
8+
"version": "17.0.2.0.0",
9+
"author": "LasLabs, "
10+
"Onestein, "
11+
"Kaushal Prajapati, "
12+
"Tecnativa, "
13+
"initOS GmbH, "
14+
"Omar Nasr, "
15+
"Odoo Community Association (OCA)",
16+
"category": "Base",
17+
"depends": [
18+
"auth_signup",
19+
"auth_password_policy_signup",
20+
],
21+
"website": "https://github.com/OCA/server-auth",
22+
"license": "LGPL-3",
23+
"data": [
24+
"views/res_config_settings_views.xml",
25+
"security/ir.model.access.csv",
26+
"security/res_users_pass_history.xml",
27+
],
28+
"demo": [
29+
"demo/res_users.xml",
30+
],
31+
"post_init_hook": "init_config_parameters",
32+
"installable": True,
33+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2015 LasLabs Inc.
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from . import main
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright 2015 LasLabs Inc.
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
import logging
5+
6+
from werkzeug.exceptions import BadRequest
7+
8+
from odoo import http
9+
from odoo.http import request
10+
11+
from odoo.addons.auth_signup.controllers.main import AuthSignupHome
12+
from odoo.addons.web.controllers.home import ensure_db
13+
14+
_logger = logging.getLogger(__name__)
15+
16+
17+
class PasswordSecurityHome(AuthSignupHome):
18+
def do_signup(self, qcontext):
19+
password = qcontext.get("password")
20+
user = request.env.user
21+
user._check_password(password)
22+
return super().do_signup(qcontext)
23+
24+
@http.route()
25+
def web_login(self, *args, **kw):
26+
ensure_db()
27+
response = super().web_login(*args, **kw)
28+
if not request.params.get("login_success"):
29+
return response
30+
if not request.env.user:
31+
return response
32+
# Now, I'm an authenticated user
33+
if not request.env.user._password_has_expired():
34+
return response
35+
# My password is expired, kick me out
36+
request.env.user.action_expire_password()
37+
request.session.logout(keep_db=True)
38+
# I was kicked out, so set login_success in request params to False
39+
request.params["login_success"] = False
40+
redirect = request.env.user.partner_id.signup_url
41+
return request.redirect(redirect)
42+
43+
@http.route()
44+
def web_auth_signup(self, *args, **kw):
45+
"""Try to catch all the possible exceptions not already handled
46+
in the parent method"""
47+
48+
try:
49+
qcontext = self.get_auth_signup_qcontext()
50+
except Exception:
51+
raise BadRequest from None # HTTPError: 400 Client Error: BAD REQUEST
52+
53+
try:
54+
return super().web_auth_signup(*args, **kw)
55+
except Exception as e:
56+
# Here we catch any generic exception since UserError is already
57+
# handled in parent method web_auth_signup()
58+
qcontext["error"] = str(e)
59+
response = request.render("auth_signup.signup", qcontext)
60+
response.headers["X-Frame-Options"] = "SAMEORIGIN"
61+
response.headers["Content-Security-Policy"] = "frame-ancestors 'self'"
62+
return response
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--
2+
Copyright 2016 LasLabs Inc.
3+
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
4+
-->
5+
<odoo>
6+
<record id="base.user_root" model="res.users">
7+
<field name="password_write_date" eval="datetime.now()" />
8+
</record>
9+
</odoo>

0 commit comments

Comments
 (0)