Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 10 additions & 6 deletions iap_mail_domain_blacklist/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ IAP Mail Domain BlackList
This module allows adding domains to the mail domain blacklist to prevent Odoo from assuming
that users with the same domain belong to the same organization.

Due to the nature of this module, in a multi-tenant setting, the configuration in one database
affects all databases in the Odoo instance.
Blacklisted domains are shared across all effective databases on the server.
When the db_name parameter is set, the effective databases are assumed to be the
values of that parameter. If db_name is not set and list_db is true, all
databases on the instance are considered effective databases.

**Table of contents**

Expand Down Expand Up @@ -62,10 +64,12 @@ for the change to take effect.
Known issues / Roadmap
======================

Due to a technical limitation, we cannot use http.db_list() to respect dbfilter
during module loading, as HTTP configuration is not available at that stage.
Therefore, db.list_dbs() is used instead. As a result, blacklist domains from inactive databases
will also affect running databases.
Due to a technical limitation, http.db_list() cannot be used during module
loading to respect dbfilter, because the HTTP layer is not initialized at
that stage. As a result, the module must rely on config.get('db_name') or
db.list_dbs() instead. Consequently, if list_db = True is enabled without
explicitly setting db_name in odoo.conf, blacklist domains from inactive
databases may incorrectly affect active databases.

Bug Tracker
===========
Expand Down
13 changes: 12 additions & 1 deletion iap_mail_domain_blacklist/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import logging

from odoo.exceptions import AccessDenied
from odoo.service import db
from odoo.sql_db import db_connect
from odoo.tools import config

from odoo.addons.iap.tools import iap_tools

Expand Down Expand Up @@ -33,8 +35,17 @@ def update_mail_domain_blacklist(cr):
iap_tools._MAIL_DOMAIN_BLACKLIST.update(additional_domains)


def _db_names():
if config.get("db_name"):
return [n.strip() for n in config["db_name"].split(",") if n.strip()]
try:
return db.list_dbs()
except AccessDenied:
return []


def post_load_hook():
for db_name in db.list_dbs():
for db_name in _db_names():
try:
with db_connect(db_name).cursor() as cr:
update_mail_domain_blacklist(cr)
Expand Down
6 changes: 4 additions & 2 deletions iap_mail_domain_blacklist/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
This module allows adding domains to the mail domain blacklist to prevent Odoo from assuming
that users with the same domain belong to the same organization.

Due to the nature of this module, in a multi-tenant setting, the configuration in one database
affects all databases in the Odoo instance.
Blacklisted domains are shared across all effective databases on the server.
When the db_name parameter is set, the effective databases are assumed to be the
values of that parameter. If db_name is not set and list_db is true, all
databases on the instance are considered effective databases.
10 changes: 6 additions & 4 deletions iap_mail_domain_blacklist/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Due to a technical limitation, we cannot use http.db_list() to respect dbfilter
during module loading, as HTTP configuration is not available at that stage.
Therefore, db.list_dbs() is used instead. As a result, blacklist domains from inactive databases
will also affect running databases.
Due to a technical limitation, http.db_list() cannot be used during module
loading to respect dbfilter, because the HTTP layer is not initialized at
that stage. As a result, the module must rely on config.get('db_name') or
db.list_dbs() instead. Consequently, if list_db = True is enabled without
explicitly setting db_name in odoo.conf, blacklist domains from inactive
databases may incorrectly affect active databases.
27 changes: 17 additions & 10 deletions iap_mail_domain_blacklist/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -371,8 +372,10 @@ <h1 class="title">IAP Mail Domain BlackList</h1>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/15.0/iap_mail_domain_blacklist"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/social-15-0/social-15-0-iap_mail_domain_blacklist"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/social&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows adding domains to the mail domain blacklist to prevent Odoo from assuming
that users with the same domain belong to the same organization.</p>
<p>Due to the nature of this module, in a multi-tenant setting, the configuration in one database
affects all databases in the Odoo instance.</p>
<p>Blacklisted domains are shared across all effective databases on the server.
When the db_name parameter is set, the effective databases are assumed to be the
values of that parameter. If db_name is not set and list_db is true, all
databases on the instance are considered effective databases.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand Down Expand Up @@ -408,10 +411,12 @@ <h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<p>Due to a technical limitation, we cannot use http.db_list() to respect dbfilter
during module loading, as HTTP configuration is not available at that stage.
Therefore, db.list_dbs() is used instead. As a result, blacklist domains from inactive databases
will also affect running databases.</p>
<p>Due to a technical limitation, http.db_list() cannot be used during module
loading to respect dbfilter, because the HTTP layer is not initialized at
that stage. As a result, the module must rely on config.get(‘db_name’) or
db.list_dbs() instead. Consequently, if list_db = True is enabled without
explicitly setting db_name in odoo.conf, blacklist domains from inactive
databases may incorrectly affect active databases.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
Expand Down Expand Up @@ -442,7 +447,9 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down