File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 27
27
use Framework \Email \Mailers \SMTPMailer ;
28
28
use Framework \Helpers \Isolation ;
29
29
use Framework \HTTP \AntiCSRF ;
30
+ use Framework \HTTP \CSP ;
30
31
use Framework \HTTP \Debug \HTTPCollector ;
31
32
use Framework \HTTP \Request ;
32
33
use Framework \HTTP \Response ;
@@ -1181,6 +1182,12 @@ protected static function setResponse(string $instance) : Response
1181
1182
? $ service ->setNoCache ()
1182
1183
: $ service ->setCache ($ config ['cache ' ]['seconds ' ], $ config ['cache ' ]['public ' ] ?? false );
1183
1184
}
1185
+ if ( ! empty ($ config ['csp ' ])) {
1186
+ $ service ->setCsp (new CSP ($ config ['csp ' ]));
1187
+ }
1188
+ if ( ! empty ($ config ['csp_report_only ' ])) {
1189
+ $ service ->setCspReportOnly (new CSP ($ config ['csp_report_only ' ]));
1190
+ }
1184
1191
return static ::setService ('response ' , $ service , $ instance );
1185
1192
}
1186
1193
Original file line number Diff line number Diff line change 10
10
/**
11
11
* @see App::response()
12
12
*/
13
+
14
+ use Framework \HTTP \CSP ;
15
+
13
16
return [
14
17
'default ' => [
15
18
'headers ' => [
21
24
'seconds ' => 60 ,
22
25
'public ' => true ,
23
26
],
27
+ 'csp ' => [
28
+ CSP ::defaultSrc => [
29
+ 'self ' ,
30
+ ],
31
+ CSP ::styleSrc => [
32
+ 'self ' ,
33
+ 'cdn.foo.tld ' ,
34
+ ],
35
+ ],
36
+ 'csp_report_only ' => [
37
+ CSP ::defaultSrc => [
38
+ 'self ' ,
39
+ ],
40
+ ],
24
41
'request_instance ' => 'default ' ,
25
42
],
26
43
];
You can’t perform that action at this time.
0 commit comments