Skip to content
Merged
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
23 changes: 2 additions & 21 deletions spp_demo/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ OpenSPP Demo
!! source digest: sha256:0000000000000000000000000000000000000000000000000000000000000000
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
Expand Down Expand Up @@ -138,10 +138,6 @@ Dependencies

External Python dependency: ``faker``

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.

**Table of contents**

.. contents::
Expand All @@ -150,21 +146,6 @@ External Python dependency: ``faker``
Changelog
=========

19.0.2.1.1
~~~~~~~~~~

- fix(security): deactivate the default-credential demo users (including
the ``sppadmin`` SPP admin, all created with the well-known password
``demo``) when the module is installed on a database without demo
data, so the known credentials cannot be used to log in on a
production instance. The accounts stay active on demo/evaluation
databases. Also lowers ``development_status`` from
``Production/Stable`` to ``Alpha`` so the demo module no longer
signals production-readiness. An upgrade migration applies the same
deactivation to already-installed production databases (the install
hook alone would leave existing deployments' default-credential
accounts active).

19.0.2.1.0
~~~~~~~~~~

Expand Down
54 changes: 0 additions & 54 deletions spp_demo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,5 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
import logging

from . import locale_providers
from . import models
from . import wizard

_logger = logging.getLogger(__name__)

# res.users records created with the shared, documented password "demo" by
# data/users_data.xml (including "sppadmin" with SPP admin rights). They load
# via the `data` section, so they exist after any install — including a
# production database installed without demo data, where the well-known
# credentials would be a login vector.
DEFAULT_DEMO_USER_XMLIDS = [
"spp_demo.demo_viewer",
"spp_demo.demo_officer",
"spp_demo.demo_supervisor",
"spp_demo.demo_manager",
"spp_demo.demo_admin",
]


def demo_data_enabled(env, module_name):
"""Return True if demo data was loaded for ``module_name`` on this database."""
module = env["ir.module.module"].search([("name", "=", module_name)], limit=1)
return bool(module.demo)


def deactivate_default_demo_users(env, xmlids, demo_enabled):
"""Deactivate default-credential demo users unless demo data is enabled.

On a database with demo data (an evaluation/demo instance) the accounts are
left active so demos and generators work. On a database WITHOUT demo data (a
production-style install) they are archived so the well-known ``demo``
password cannot be used to log in. Returns the users that were deactivated.
"""
if demo_enabled:
return env["res.users"].browse()
users = env["res.users"].browse()
for xmlid in xmlids:
user = env.ref(xmlid, raise_if_not_found=False)
if user and user.active:
users |= user
if users:
users.active = False
_logger.warning(
"Demo data is disabled; archived %d default-credential demo "
"user(s): %s. Re-activate them deliberately only on a "
"non-production instance.",
len(users),
", ".join(users.mapped("login")),
)
return users


def post_init_hook(env):
"""Neutralize the default-credential demo users on a production install."""
deactivate_default_demo_users(env, DEFAULT_DEMO_USER_XMLIDS, demo_data_enabled(env, "spp_demo"))
9 changes: 3 additions & 6 deletions spp_demo/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
{
"name": "OpenSPP Demo",
"category": "OpenSPP",
"version": "19.0.2.1.1",
"version": "19.0.2.1.0",
"sequence": 1,
"author": "OpenSPP.org",
"website": "https://github.com/OpenSPP/OpenSPP2",
"license": "LGPL-3",
"development_status": "Alpha",
"development_status": "Production/Stable",
"maintainers": ["jeremi", "gonzalesedwin1123", "reichie020212", "emjay0921"],
"summary": "Core demo module with data generator and sample data for OpenSPP. "
"DEMO ONLY: creates users with the well-known password 'demo' (including an "
"'sppadmin' SPP admin). Never install on a production or internet-facing instance.",
"summary": "Core demo module with data generator and sample data for OpenSPP",
"depends": [
"base",
"spp_base_common",
Expand Down Expand Up @@ -45,5 +43,4 @@
"application": False,
"installable": True,
"auto_install": False,
"post_init_hook": "post_init_hook",
}
9 changes: 0 additions & 9 deletions spp_demo/data/users_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@

Login credentials: username / demo
==========================================================================

SECURITY: on a database without demo data (a production-style install)
these default-credential users are archived by spp_demo's post_init_hook
(see __init__.py). That hook runs on install only. These records
intentionally set NO `active` field, so an upgrade re-run of this
noupdate="0" file does not reactivate archived users. Do NOT add
`<field name="active" eval="True"/>` here without also re-archiving on
upgrade, or a production upgrade would silently re-enable the accounts.
==========================================================================
-->

<!-- VIEWER: Read-only access across domains -->
Expand Down
25 changes: 0 additions & 25 deletions spp_demo/migrations/19.0.2.1.1/post-migration.py

This file was deleted.

12 changes: 0 additions & 12 deletions spp_demo/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
### 19.0.2.1.1

- fix(security): deactivate the default-credential demo users (including the
``sppadmin`` SPP admin, all created with the well-known password ``demo``)
when the module is installed on a database without demo data, so the known
credentials cannot be used to log in on a production instance. The accounts
stay active on demo/evaluation databases. Also lowers ``development_status``
from ``Production/Stable`` to ``Alpha`` so the demo module no longer signals
production-readiness. An upgrade migration applies the same deactivation to
already-installed production databases (the install hook alone would leave
existing deployments' default-credential accounts active).

### 19.0.2.1.0

- feat(demo): re-land curated PHL geodata and demo generator updates from #76: refreshed `data/shapes/phl_curated.geojson` and `data/countries/phl/areas.xml` (prepared via `scripts/prepare_phl_geodata.py`), with matching demo data generator and area loader test updates. Adds the companion `spp_demo_phl_luzon` module providing Luzon-scale demo areas and population weights.
Expand Down
25 changes: 2 additions & 23 deletions spp_demo/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">OpenSPP Demo</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0000000000000000000000000000000000000000000000000000000000000000
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OpenSPP/OpenSPP2/tree/19.0/spp_demo"><img alt="OpenSPP/OpenSPP2" src="https://img.shields.io/badge/github-OpenSPP%2FOpenSPP2-lightgray.png?logo=github" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OpenSPP/OpenSPP2/tree/19.0/spp_demo"><img alt="OpenSPP/OpenSPP2" src="https://img.shields.io/badge/github-OpenSPP%2FOpenSPP2-lightgray.png?logo=github" /></a></p>
<p>Demo data generator for OpenSPP with Faker-based random registrant
creation and fixed demo stories. Generates realistic individuals and
groups with locale-specific data providers. Includes predefined personas
Expand Down Expand Up @@ -514,11 +514,6 @@ <h1>Dependencies</h1>
<p><tt class="docutils literal">base</tt>, <tt class="docutils literal">spp_base_common</tt>, <tt class="docutils literal">spp_registry</tt>, <tt class="docutils literal">spp_vocabulary</tt>,
<tt class="docutils literal">queue_job</tt>, <tt class="docutils literal">spp_security</tt></p>
<p>External Python dependency: <tt class="docutils literal">faker</tt></p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.</p>
</div>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -530,22 +525,6 @@ <h2><a class="toc-backref" href="#toc-entry-1">Changelog</a></h2>
</div>
</div>
<div class="section" id="section-1">
<h1>19.0.2.1.1</h1>
<ul class="simple">
<li>fix(security): deactivate the default-credential demo users (including
the <tt class="docutils literal">sppadmin</tt> SPP admin, all created with the well-known password
<tt class="docutils literal">demo</tt>) when the module is installed on a database without demo
data, so the known credentials cannot be used to log in on a
production instance. The accounts stay active on demo/evaluation
databases. Also lowers <tt class="docutils literal">development_status</tt> from
<tt class="docutils literal">Production/Stable</tt> to <tt class="docutils literal">Alpha</tt> so the demo module no longer
signals production-readiness. An upgrade migration applies the same
deactivation to already-installed production databases (the install
hook alone would leave existing deployments’ default-credential
accounts active).</li>
</ul>
</div>
<div class="section" id="section-2">
<h1>19.0.2.1.0</h1>
<ul class="simple">
<li>feat(demo): re-land curated PHL geodata and demo generator updates
Expand All @@ -557,7 +536,7 @@ <h1>19.0.2.1.0</h1>
population weights.</li>
</ul>
</div>
<div class="section" id="section-3">
<div class="section" id="section-2">
<h1>19.0.2.0.0</h1>
<ul class="simple">
<li>Initial migration to OpenSPP2</li>
Expand Down
1 change: 0 additions & 1 deletion spp_demo/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
from . import test_apps_wizard
from . import test_demo_stories
from . import test_demo_area_loader
from . import test_demo_user_safety
79 changes: 0 additions & 79 deletions spp_demo/tests/test_demo_user_safety.py

This file was deleted.

21 changes: 2 additions & 19 deletions spp_farmer_registry_demo/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ OpenSPP Farmer Registry Demo
!! source digest: sha256:force_regen
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
Expand Down Expand Up @@ -112,10 +112,6 @@ Dependencies
``spp_farmer_registry_cr``, ``spp_studio``,
``spp_registry_group_hierarchy``, ``spp_area``, ``spp_programs``

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.

**Table of contents**

.. contents::
Expand All @@ -124,19 +120,6 @@ Dependencies
Changelog
=========

19.0.2.1.6
~~~~~~~~~~

- fix(security): deactivate this module's default-credential demo users
(created with the well-known password ``demo``) when installed on a
database without demo data, so the known credentials cannot be used to
log in on a production instance; the accounts stay active on
demo/evaluation databases. An upgrade migration applies the same
deactivation to already-installed production databases, not just fresh
installs. Also lowers ``development_status`` from
``Production/Stable`` to ``Alpha`` so the demo module no longer
signals production-readiness.

19.0.2.1.5
~~~~~~~~~~

Expand Down
17 changes: 0 additions & 17 deletions spp_farmer_registry_demo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
from . import models

# Farmer-registry-specific demo users created with the well-known password
# "demo" by data/demo_users.xml (in addition to the spp_demo users this module
# re-roles, which spp_demo's own post_init_hook already neutralizes).
DEFAULT_DEMO_USER_XMLIDS = [
"spp_farmer_registry_demo.demo_user_cr_local_validator",
"spp_farmer_registry_demo.demo_user_cr_hq_validator",
"spp_farmer_registry_demo.demo_user_program_manager",
"spp_farmer_registry_demo.demo_user_cycle_approver",
]


def post_init_hook(env):
"""Neutralize this module's default-credential demo users in production."""
from odoo.addons.spp_demo import deactivate_default_demo_users, demo_data_enabled

deactivate_default_demo_users(env, DEFAULT_DEMO_USER_XMLIDS, demo_data_enabled(env, "spp_farmer_registry_demo"))
Loading
Loading