1 | <?php |
||
13 | class Csp |
||
14 | { |
||
15 | /** |
||
16 | * @var CSPBuilder |
||
17 | */ |
||
18 | private $csp; |
||
19 | |||
20 | /** |
||
21 | * Set CSPBuilder. |
||
22 | * |
||
23 | * @param array|null $policies |
||
24 | */ |
||
25 | public function __construct(array $policies = null) |
||
39 | |||
40 | /** |
||
41 | * Add a source to our allow whitelist. |
||
42 | * |
||
43 | * @param string $directive |
||
44 | * @param string $path |
||
45 | * |
||
46 | * @return self |
||
47 | */ |
||
48 | public function addSource($directive, $path) |
||
54 | |||
55 | /** |
||
56 | * Add a directive if it doesn't already exist |
||
57 | * If it already exists, do nothing. |
||
58 | * |
||
59 | * @param string $directive |
||
60 | * @param mixed $value |
||
61 | * |
||
62 | * @return self |
||
63 | */ |
||
64 | public function addDirective($directive, $value) |
||
70 | |||
71 | /** |
||
72 | * Whether or not support old browsers (e.g. safari). |
||
73 | * |
||
74 | * @param bool $support |
||
75 | * |
||
76 | * @return self |
||
77 | */ |
||
78 | public function supportOldBrowsers($support = true) |
||
88 | |||
89 | /** |
||
90 | * Execute the middleware. |
||
91 | * |
||
92 | * @param ServerRequestInterface $request |
||
93 | * @param ResponseInterface $response |
||
94 | * @param callable $next |
||
95 | * |
||
96 | * @return ResponseInterface |
||
97 | */ |
||
98 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
106 | } |
||
107 |