summaryrefslogtreecommitdiffstats
path: root/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php')
-rw-r--r--lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php b/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php
index 64d4eb6e5d0..d0536259f7a 100644
--- a/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php
+++ b/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php
@@ -68,6 +68,8 @@ class EmptyContentSecurityPolicy {
protected $allowedFontDomains = null;
/** @var array Domains from which web-workers and nested browsing content can load elements */
protected $allowedChildSrcDomains = null;
+ /** @var array Domains which can embeed this Nextcloud instance */
+ protected $allowedFrameAncestors = null;
/**
* Whether inline JavaScript snippets are allowed or forbidden
@@ -327,6 +329,30 @@ class EmptyContentSecurityPolicy {
}
/**
+ * Domains which can embeed an iFrame of the Nextcloud instance
+ *
+ * @param string $domain
+ * @return $this
+ * @since 12.x
+ */
+ public function addAllowedFrameAncestorDomain($domain) {
+ $this->allowedFrameAncestors[] = $domain;
+ return $this;
+ }
+
+ /**
+ * Domains which can embeed an iFrame of the Nextcloud instance
+ *
+ * @param string $domain
+ * @return $this
+ * @since 12.x
+ */
+ public function disallowFrameAncestorDomain($domain) {
+ $this->allowedFrameAncestors = array_diff($this->allowedFrameAncestors, [$domain]);
+ return $this;
+ }
+
+ /**
* Get the generated Content-Security-Policy as a string
* @return string
* @since 8.1.0
@@ -405,6 +431,11 @@ class EmptyContentSecurityPolicy {
$policy .= ';';
}
+ if(!empty($this->allowedFrameAncestors)) {
+ $policy .= 'frame-ancestors ' . implode(' ', $this->allowedFrameAncestors);
+ $policy .= ';';
+ }
+
return rtrim($policy, ';');
}
}