-
-
Notifications
You must be signed in to change notification settings - Fork 143
[IMP] add server settings for CORS #795
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
Open
RaoufGhrissi
wants to merge
1
commit into
ActivityWatch:master
Choose a base branch
from
odoo:ref/cors-settings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| <template lang="pug"> | ||
| div | ||
| h4.mb-3 Security & CORS | ||
|
|
||
| b-alert(show variant="info" class="mb-4") | ||
| h5.alert-heading Require Restart | ||
| p.mb-0 Changing settings in this section requires stopping and restarting the server for the changes to take effect. | ||
|
|
||
| b-form-group(label="Fixed CORS origins" label-cols-md=4 description="Configure general CORS origins with exact matches (e.g. http://localhost:8080). Comma-separated.") | ||
| b-input(v-model="cors" type="text") | ||
|
|
||
| b-form-group(label="Regex CORS origins" label-cols-md=4 description="Configure CORS origins with regular expressions. Useful for browser extensions (e.g. chrome-extension://.* or moz-extension://.*). Comma-separated.") | ||
| b-input(v-model="corsregex" type="text") | ||
|
|
||
| h5.mt-4 Extensions Shortcuts | ||
| b-form-group(label-cols-md=4) | ||
| b-form-checkbox(v-model="cors_allow_aw_chrome_extension") Allow ActivityWatch extension (Chrome) | ||
| template(#description) | ||
| div Chrome extensions use a stable, persistent ID, so the official extension is reliably supported. | ||
|
|
||
| b-form-group(label-cols-md=4) | ||
| b-form-checkbox(v-model="cors_allow_all_mozilla_extension") Allow all Firefox extensions (DANGEROUS) | ||
| template(#description) | ||
| div Every version of a Mozilla extension has its own ID to avoid fingerprinting. This is why you must either allow all extensions or manually configure your specific ID. | ||
| div.mt-2.text-danger(v-if="cors_allow_all_mozilla_extension") | ||
| | ⚠️ DANGEROUS: Not recommended for security. If enabled, any installed extension can access your ActivityWatch data. Use this only if you know what extensions you have and assume full responsibility. | ||
| div(v-else) | ||
| | Recommended for security. To allow a specific extension safely: | ||
| ol.mt-2.mb-1 | ||
| li Go to <code>about:debugging#/runtime/this-firefox</code> in your browser. | ||
| li Look for your extension and copy the <b>Manifest URL</b> (e.g. <code>moz-extension://4b931c07dededdedff152/manifest.json</code>). | ||
| li Remove <code>manifest.json</code> from the end (to get <code>moz-extension://4b931c07dededdedff152</code>). | ||
| li Paste it into the <b>Regex CORS origins</b> field above (use a comma to separate if not empty). | ||
|
|
||
|
|
||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import { useSettingsStore } from '~/stores/settings'; | ||
|
|
||
| export default { | ||
|
|
||
| computed: { | ||
| cors: { | ||
| get() { | ||
| return useSettingsStore().cors; | ||
| }, | ||
| set(cors) { | ||
| useSettingsStore().update({ cors }); | ||
| }, | ||
| }, | ||
| corsregex: { | ||
| get() { | ||
| return useSettingsStore().cors_regex; | ||
| }, | ||
| set(cors_regex) { | ||
| useSettingsStore().update({ cors_regex }); | ||
| }, | ||
| }, | ||
| cors_allow_aw_chrome_extension: { | ||
| get() { | ||
| return useSettingsStore().cors_allow_aw_chrome_extension; | ||
| }, | ||
| set(cors_allow_aw_chrome_extension) { | ||
| useSettingsStore().update({ cors_allow_aw_chrome_extension }); | ||
| }, | ||
| }, | ||
| cors_allow_all_mozilla_extension: { | ||
| get() { | ||
| return useSettingsStore().cors_allow_all_mozilla_extension; | ||
| }, | ||
| set(cors_allow_all_mozilla_extension) { | ||
| useSettingsStore().update({ cors_allow_all_mozilla_extension }); | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Step 3 tells the user to paste a raw
moz-extension://...URL (e.g.moz-extension://4b931c07deded...ff152) into the Regex CORS origins field. However, the dots (.) in that URL are regex metacharacters that match any character, so the pattern will also match origins with different characters in those positions. This could allow an unintended extension to bypass the CORS check.Consider updating the instructions to advise users to escape literal dots with
\., or direct them to paste the origin into the Fixed CORS origins field instead (which uses exact matching), if the backend supports it.