Comments (13)
Hi,
hit the same bug.
Notice: i host nextcloud / owncloud and piwik on the same domain.
first i noticed there is no 'self' in the CSP header so i looked how to fix this issue
found some infos in the nextcloud community forums: https://help.nextcloud.com/t/content-security-policy-in-nextcloud/5288/4
tried tweaking the piwik\appinfo\app.php :
if (array_key_exists('HTTP_HOST', $_SERVER) && $_SERVER['HTTP_HOST'] !== $url) {
$policy = new OCP\AppFramework\Http\ContentSecurityPolicy ();
$policy->addAllowedScriptDomain($url);
$policy->addAllowedImageDomain($url);
\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy);
} else {
$policy = new OCP\AppFramework\Http\ContentSecurityPolicy ();
$policy->addAllowedScriptDomain('\'self\'');
$policy->addAllowedImageDomain('\'self\'');
\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy);
}
unfortunately this doesn't has the desired effect (no self in the CSP Header)
so i ended up with this tweak:
# if (array_key_exists('HTTP_HOST', $_SERVER) && $_SERVER['HTTP_HOST'] !== $url) {
$policy = new OCP\AppFramework\Http\ContentSecurityPolicy ();
$policy->addAllowedScriptDomain($url);
$policy->addAllowedImageDomain($url);
\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy);
# }
aka commented the HTTP_HOST header check in app.php
maybe someone knows an better solution for this issue :-)
regards Alex
from cloud_piwik.
Hey Alex,
thank you! Finally I can track my NextCloud ;)
Thanks for sharing your solution!
Regards, Nils
from cloud_piwik.
Mh. I think the cleaner solution would be to improve the host/url check. But anyway I am wondering, why self is missing in the csp header...
from cloud_piwik.
I also encounter this issue on Nextcloud 11, but the effect depends on the browser...with the default code, tracking works on Safari, IE and Edge but fails with Firefox and Chrome. Modifying the code like Alex-Ba suggests "works" but I'm really not skilled enough to track the root cause and fix anything.
from cloud_piwik.
The problem comes from the parse_url
$piwik = json_decode(OCP\Config::getAppValue('piwik', 'piwik'));
# Comment out the parse url and add your URL here
# $url = parse_url($piwik->url, PHP_URL_HOST);
$url = 'piwik.MY_URL.cc';
# if (array_key_exists('HTTP_HOST', $_SERVER) && $_SERVER['HTTP_HOST'] !== $url) {
$policy = new OCP\AppFramework\Http\ContentSecurityPolicy ();
$policy->addAllowedScriptDomain($url);
$policy->addAllowedImageDomain($url);
\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy);
# }
}
from cloud_piwik.
@Xqua can you explain that in more detail? What is the value of $piwik->url
and the corresponding return value of parse_url
?
from cloud_piwik.
I did this a while back ... I think it was returning a nil or some sort.
from cloud_piwik.
Hope the fix works for you guys.
from cloud_piwik.
I'll try it next week and get back to you !
from cloud_piwik.
The errors re-appears in Nextcloud 16.
- PHP7.3
- MariaDB
- Debian 9.9 stretch
- NGINX 1.16 TLSv1.2
All of your mentioned fixes causes the app to change its state from being enabled to disabled.
May i ask and please you to re-investigate further? If you are interested in - let me know how to assist you or grant access to my environment.
Cheers, Carsten (https://www.c-rieger.de)
from cloud_piwik.
I gave up on NextCloud, sorry I won't be able to help.
from cloud_piwik.
@criegerde #70 should fix it, please let me know if it doesn't.
The addon will be disabled if the app is not marked as compliant (e.g. error in code)
from cloud_piwik.
@MinIsMin : Great, it works with #70
Many THANKS!
from cloud_piwik.
Related Issues (20)
- [Feature Request] Tracking analytics for OnlyOffice / Community Document Server views HOT 3
- Compatibility with Nextcloud 28 and 29 HOT 3
- No tracking after upgrade to to 0.5.0 - 404 error for tracking.js HOT 15
- Call to undefined method OC\Server::getContentSecurityPolicyNonceManager() (Owncloud no longer supported?) HOT 3
- Update for compatibility with nextcloud 16 needed HOT 6
- Undefined index: host at /cloud/apps/piwik/appinfo/app.php#14
- Feature Request : Track Uploads/Downloads (why not ?) HOT 4
- Not compatible with Nexcloud 18 HOT 1
- File download tracking HOT 1
- Add support for Nextcloud 19 HOT 5
- Matomo isn't tracking calls HOT 1
- Mobile Track from nextcloud Module HOT 1
- "Content Security Policy" errors in Nextcloud for calls to Matoma HOT 5
- Is it possible to track media plays? HOT 3
- Nextcloud 22 support HOT 3
- Nextcloud 24 support HOT 7
- numbers downloaded files HOT 1
- Unable to install latest version `0.11.0` HOT 2
- [Feature Request] Tracking sharing download HOT 1
- Support for NC 26 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloud_piwik.