Skip to content

Commit

Permalink
Merge PR #610 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Nov 16, 2024
2 parents def9106 + ce6c04d commit c5c58ad
Show file tree
Hide file tree
Showing 99 changed files with 24,394 additions and 0 deletions.
133 changes: 133 additions & 0 deletions password_security/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
=================
Password Security
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dc29155c73a519d3732e2806f60bd11ebb31cd8c181ebd5918e4bc68080d37aa
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/17.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-17-0/server-auth-17-0-password_security
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=17.0
:alt: Try me on Runboat

|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:

[TABLE]

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 to smash it by providing a detailed and welcomed
`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**>`_.

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

Credits
=======

Authors
-------

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

Contributors
------------

- James Foster <[email protected]>

- Dave Lasley <[email protected]>

- Kaushal Prajapati <[email protected]>

- Petar Najman <[email protected]>

- Shepilov Vladislav <[email protected]>

- Florian Kantelberg <[email protected]>

- Dhara Solanki <[email protected]>

- `Open Source Integrators <https://opensourceintegrators.com>`__

- Chandresh Thakkar <[email protected]>
- Daniel Reis <[email protected]>

- `Onestein <https://www.onestein.nl>`__:

- Andrea Stirpe <[email protected]>

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/17.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 <[email protected]>.
# 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": "17.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().do_signup(qcontext)

@http.route()
def web_login(self, *args, **kw):
ensure_db()
response = super().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().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 c5c58ad

Please sign in to comment.