Giter VIP home page Giter VIP logo

Comments (13)

Alex-Ba avatar Alex-Ba commented on August 27, 2024 1

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.

npXXX avatar npXXX commented on August 27, 2024

Hey Alex,
thank you! Finally I can track my NextCloud ;)
Thanks for sharing your solution!

Regards, Nils

from cloud_piwik.

sualko avatar sualko commented on August 27, 2024

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.

smoix avatar smoix commented on August 27, 2024

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.

Xqua avatar Xqua commented on August 27, 2024

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.

sualko avatar sualko commented on August 27, 2024

@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.

Xqua avatar Xqua commented on August 27, 2024

I did this a while back ... I think it was returning a nil or some sort.

from cloud_piwik.

sualko avatar sualko commented on August 27, 2024

Hope the fix works for you guys.

from cloud_piwik.

Xqua avatar Xqua commented on August 27, 2024

I'll try it next week and get back to you !

from cloud_piwik.

 avatar commented on August 27, 2024

The errors re-appears in Nextcloud 16.

  • PHP7.3
  • MariaDB
  • Debian 9.9 stretch
  • NGINX 1.16 TLSv1.2

grafik

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.

Xqua avatar Xqua commented on August 27, 2024

I gave up on NextCloud, sorry I won't be able to help.

from cloud_piwik.

MinIsMin avatar MinIsMin commented on August 27, 2024

@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.

 avatar commented on August 27, 2024

@MinIsMin : Great, it works with #70
Many THANKS!

from cloud_piwik.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.