Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] password_security #239

Merged
merged 39 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
55034ce
[9.0][ADD] Password Security Settings (#531)
lasley Sep 29, 2016
2802ef3
[MIG] Make modules uninstallable
pedrobaeza Oct 6, 2016
c844929
[MIG] Rename manifest files
pedrobaeza Oct 6, 2016
5042c45
[MIG] password_security: Migrate to v10
lasley Oct 20, 2016
2619aa1
[FIX] password_security: Validate admin pass
lasley Dec 23, 2016
249733e
[FIX] password_security: Fix history rule
lasley Jan 9, 2017
b052e8b
Improve UX password_match_message()
astirpe May 5, 2017
a083876
[FIX] password_security: Fix password stored and token to reset passw…
moylop260 Jun 20, 2017
77404e5
[FIX] password_security: Force password reset
obulkin Sep 18, 2017
1244f6c
[MIG]password security
smurf-U Oct 11, 2017
51b20eb
[IMP]change request
smurf-U Oct 27, 2017
8d40820
[IMP]Underscore is a special character #1077
StefanRijnhart Nov 29, 2017
6c3ecf7
[FIX] password_security: Default last write date #1084
lasley Dec 4, 2017
65c02c6
[FIX] UTF-8 coding is not necessary
max3903 Mar 28, 2018
c364f4d
[MIG] auth_totp_password_security: Migration to 11.0
MiquelRForgeFlow May 14, 2018
9ba0fb6
[I18N] password_security: Translate to Spanish all translatable terms
luisg123v Jun 18, 2018
95ab84c
[FIX] password_security: Error 500 when login with bad password (#27)
yajo Jun 19, 2018
2cd9c60
[FIX] password_security: Allow mini-admin to create users (#31)
yajo Jun 22, 2018
dc0a062
[FIX] password_security: Make tests pass if website is installed
yajo Nov 27, 2018
c265aad
[UPD] Update password_security.pot
oca-travis Dec 12, 2018
ef5ba82
[MIG] password_security: Migration to 12.0
shepilov-vladislav Apr 12, 2019
8bd8191
[FIX] password_security: correct readme fragments
sbidoul May 11, 2019
09924e9
[UPD] README.rst
OCA-git-bot May 11, 2019
1557ddf
[FIX] 12.0 `password_security` - Reset Password
amkarthik Jul 18, 2019
dabbf0b
[FIX] 12.0 `password_security` - Reset Password
amkarthik Jul 22, 2019
8a56888
[UPD] README.rst
OCA-git-bot Jul 29, 2019
5814493
Add zxcvbn to password security
fkantelberg Sep 1, 2019
b16f29d
Force add zxcvbn js lib
fkantelberg Sep 7, 2019
72c17c5
[UPD] README.rst
OCA-git-bot Oct 1, 2019
ba10d85
Translated using Weblate (Croatian)
badbole Nov 13, 2019
c7f2e8f
[FIX] [12.0] password_security - redirection fails when password_secu…
amkarthik Jul 23, 2019
3878aed
password_security 12.0.1.1.2
OCA-git-bot Mar 30, 2020
f230f43
making password_security compatible with odoo 13.0
Moro-Code Apr 23, 2020
e3ce140
add external dependency
Moro-Code Apr 27, 2020
dd77b23
Translated using Weblate (Portuguese)
pedrocs-exo Oct 12, 2020
220bb72
Translated using Weblate (Portuguese)
pedrocs-exo Oct 13, 2020
0608afc
[UPD] Update password_security.pot
oca-travis Nov 30, 2020
2c8b9bd
Update translation files
oca-transbot Nov 30, 2020
0618075
Reformat password_security to match tests
llacroix Dec 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ max-complexity = 16
# B9 = bugbear opinionated (incl line length)
select = C,E,F,W,B,B9
# E203: whitespace before ':' (black behaviour)
# E231: missing whitespace after ',' (black behaviour)
# E501: flake8 line length (covered by bugbear B950)
# W503: line break before binary operator (black behaviour)
ignore = E203,E501,W503
ignore = E203,E231,E501,W503
126 changes: 126 additions & 0 deletions password_security/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
=================
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/12.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-12-0/server-auth-12-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/12.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
* Password strength estimation

**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
password_estimate 3 Required score for the strength estimation.
===================== ======= ===================================================

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:%2012.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

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>

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/12.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
28 changes: 28 additions & 0 deletions password_security/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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": "13.0.1.0.0",
"author": "LasLabs, "
"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",
"external_dependencies": {"python": ["zxcvbn"],},
"license": "LGPL-3",
"data": [
"views/password_security.xml",
"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
81 changes: 81 additions & 0 deletions password_security/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2015 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

import operator

from odoo import http
from odoo.http import request

from odoo.addons.auth_signup.controllers.main import AuthSignupHome
from odoo.addons.web.controllers.main import Session, ensure_db

from ..exceptions import PassError


class PasswordSecuritySession(Session):
@http.route()
def change_password(self, fields):
new_password = operator.itemgetter("new_password")(
dict(list(map(operator.itemgetter("name", "value"), fields)))
)
user_id = request.env.user
user_id._check_password(new_password)
return super(PasswordSecuritySession, self).change_password(fields)


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

@http.route("/password_security/estimate", auth="none", type="json")
def estimate(self, password):
return request.env["res.users"].get_estimation(password)

@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
# 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 http.redirect_with_hash(redirect)

@http.route()
def web_auth_signup(self, *args, **kw):
try:
return super(PasswordSecurityHome, self).web_auth_signup(*args, **kw)
except PassError as e:
qcontext = self.get_auth_signup_qcontext()
qcontext["error"] = str(e)
return request.render("auth_signup.signup", qcontext)

@http.route()
def web_auth_reset_password(self, *args, **kw):
"""It provides hook to disallow front-facing resets inside of min
Unfortuantely had to reimplement some core logic here because of
nested logic in parent
"""
qcontext = self.get_auth_signup_qcontext()
if (
request.httprequest.method == "POST"
and qcontext.get("login")
and "error" not in qcontext
and "token" not in qcontext
):
login = qcontext.get("login")
user_ids = request.env.sudo().search([("login", "=", login)], limit=1,)
if not user_ids:
user_ids = request.env.sudo().search([("email", "=", login)], limit=1,)
user_ids._validate_pass_reset()
return super(PasswordSecurityHome, self).web_auth_reset_password(*args, **kw)
10 changes: 10 additions & 0 deletions password_security/demo/res_users.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
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>
12 changes: 12 additions & 0 deletions password_security/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2015 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from odoo.exceptions import Warning as UserError


class PassError(UserError):
""" Example: When you try to create an insecure password."""

def __init__(self, msg):
self.message = msg
super(PassError, self).__init__(msg)
Loading