summaryrefslogtreecommitdiffstats
path: root/Bugzilla/CGI
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/CGI')
-rw-r--r--Bugzilla/CGI/Mojo.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/Bugzilla/CGI/Mojo.pm b/Bugzilla/CGI/Mojo.pm
index e3adf1133..2d4f40d3e 100644
--- a/Bugzilla/CGI/Mojo.pm
+++ b/Bugzilla/CGI/Mojo.pm
@@ -14,6 +14,23 @@ has 'controller' => (
handles => [qw(param cookie)],
);
+has 'content_security_policy' => (
+ is => 'lazy',
+);
+
+sub _build_content_security_policy {
+ my ($self) = @_;
+ my $csp = $self->controller->stash->{content_security_policy} // { Bugzilla::CGI::DEFAULT_CSP() };
+ return Bugzilla::CGI::ContentSecurityPolicy->new( $csp );
+}
+
+sub csp_nonce {
+ my ($self) = @_;
+
+ my $csp = $self->content_security_policy;
+ return $csp->has_nonce ? $csp->nonce : '';
+}
+
sub script_name {
my ($self) = @_;