policy.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { BrowserPolicy } from 'meteor/browser-policy-common';
  2. Meteor.startup(() => {
  3. if ( process.env.BROWSER_POLICY_ENABLED === 'true' ) {
  4. // Trusted URL that can embed Wekan in iFrame.
  5. const trusted = process.env.TRUSTED_URL;
  6. BrowserPolicy.framing.disallow();
  7. BrowserPolicy.content.disallowInlineScripts();
  8. BrowserPolicy.content.disallowEval();
  9. BrowserPolicy.content.allowInlineStyles();
  10. BrowserPolicy.content.allowFontDataUrl();
  11. BrowserPolicy.framing.restrictToOrigin(trusted);
  12. BrowserPolicy.content.allowScriptOrigin(trusted);
  13. }
  14. else {
  15. // Disable browser policy and allow all framing and including.
  16. // Use only at internal LAN, not at Internet.
  17. BrowserPolicy.framing.allowAll();
  18. BrowserPolicy.content.allowDataUrlForAll();
  19. }
  20. // Allow all images from anywhere
  21. BrowserPolicy.content.allowImageOrigin('*');
  22. // If Matomo URL is set, allow it.
  23. const matomoUrl = process.env.MATOMO_ADDRESS;
  24. if (matomoUrl){
  25. BrowserPolicy.content.allowScriptOrigin(matomoUrl);
  26. BrowserPolicy.content.allowImageOrigin(matomoUrl);
  27. }
  28. });