Skip to content

[SEC] restrict CORS to authorized extension IDs and migrate settings#2

Open
RaoufGhrissi wants to merge 2 commits intomasterfrom
master-configure-cors
Open

[SEC] restrict CORS to authorized extension IDs and migrate settings#2
RaoufGhrissi wants to merge 2 commits intomasterfrom
master-configure-cors

Conversation

@RaoufGhrissi
Copy link
Copy Markdown

@RaoufGhrissi RaoufGhrissi commented Apr 14, 2026

[SEC] restrict CORS to authorized extension IDs and migrate settings
Problem:

  1. Security: Firefox extensions had a blanket wildcard permission (moz-extension://.*).
  2. Bug: CORS settings were stored in the general 'settings.' namespace (settings.cors_origins), which would overwrite values from config.toml and didn't support regex properly (causing panics if regex was used).

Solution:

  1. Restricted CORS to authorized extension IDs and introduced a dedicated 'cors-config' API and 'cors.' namespace in the datastore.
  2. Implemented a migration script that moves existing 'settings.cors_origins' values to 'cors.cors' on startup.
  3. Updated the CORS middleware to handle multiple origin sources (TOML, datastore exact/regex matches, and extension shortcuts).
  4. Ensured that fields defined in config.toml are respected and non-editable through the UI, preventing accidental overwrites.
  5. Added validation for regex patterns to prevent server panics.

Refactored the Web UI to use a dedicated CORS configuration modal and store, providing granular control over security settings.

Related PRs: https://github.com/odoo/aw-webui/pull/2/changes

Problem:
Settings changes (UI preferences, startOfWeek) were being lost on server shutdown because they were waiting for a 15-second background commit timer.

Solution:
Ensure that SetKeyValue and DeleteKeyValue commands set self.commit = true in the datastore worker, forcing immediate persistence.

Steps to Reproduce:
1. Start aw-server-rust.
2. Change a setting (e.g. startOfWeek).
3. Immediately kill the server: pkill -TERM aw-server.
4. Restart and check the setting.
@RaoufGhrissi RaoufGhrissi force-pushed the master-configure-cors branch 5 times, most recently from 332ca11 to eb367e7 Compare April 15, 2026 10:04
Problem:
1. Security: Firefox extensions had a blanket wildcard permission (moz-extension://.*).
2. Bug: CORS settings were stored in the general 'settings.' namespace (settings.cors_origins), which would overwrite values from config.toml and didn't support regex properly (causing panics if regex was used).

Solution:
1. Restricted CORS to authorized extension IDs and introduced a dedicated 'cors-config' API and 'cors.' namespace in the datastore.
2. Implemented a migration script that moves existing 'settings.cors_origins' values to 'cors.cors' on startup.
3. Updated the CORS middleware to handle multiple origin sources (TOML, datastore exact/regex matches, and extension shortcuts).
4. Ensured that fields defined in config.toml are respected and non-editable through the UI, preventing accidental overwrites.
5. Added validation for regex patterns to prevent server panics.

Refactored the backend to use a dedicated CORS configuration model, allowing granular control over security settings.

Related PRs: https://github.com/odoo/aw-webui/pull/2/changes
@RaoufGhrissi RaoufGhrissi force-pushed the master-configure-cors branch from eb367e7 to 8f7cafc Compare April 15, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant