1 | <?php namespace Stevenmaguire\Laravel\Http\Middleware; |
||
10 | class EnforceContentSecurity extends BaseMiddleware |
||
11 | { |
||
12 | /** |
||
13 | * Config closure; |
||
14 | * |
||
15 | * @var Closure |
||
16 | */ |
||
17 | protected $config; |
||
18 | |||
19 | /** |
||
20 | * Creates new middleware instance. |
||
21 | */ |
||
22 | 6 | public function __construct() |
|
34 | |||
35 | /** |
||
36 | * Handles an incoming request. |
||
37 | * |
||
38 | * @param \Illuminate\Http\Request $request |
||
39 | * @param \Closure $next |
||
40 | * @return mixed |
||
41 | */ |
||
42 | 6 | public function handle($request, Closure $next) |
|
67 | |||
68 | /** |
||
69 | * Creates Laravel response object from PSR 7 response. |
||
70 | * |
||
71 | * @param ResponseInterface $response |
||
72 | * |
||
73 | * @return Response |
||
74 | */ |
||
75 | 4 | protected function createLaravelResponse(ResponseInterface $response) |
|
83 | |||
84 | /** |
||
85 | * Creates PSR 7 response object from Laravel response. |
||
86 | * |
||
87 | * @param Response $response |
||
88 | * |
||
89 | * @return ResponseInterface |
||
90 | */ |
||
91 | 4 | protected function createPsr7Response(Response $response) |
|
100 | |||
101 | /** |
||
102 | * Retrives profile configuration from Laravel config object. |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | 4 | protected function getProfileConfig() |
|
117 | |||
118 | /** |
||
119 | * Retrieves configuration key associated with content security profiles. |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | 4 | protected function getProfileConfigKey() |
|
127 | |||
128 | /** |
||
129 | * Gets profiles from handle method arguments. |
||
130 | * |
||
131 | * @param array $arguments |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 4 | protected function getProfilesFromArguments(array $arguments) |
|
145 | |||
146 | /** |
||
147 | * Updates config callable used to access application configuration data. |
||
148 | * |
||
149 | * @param Closure $config |
||
150 | * |
||
151 | * @return EnforceContentSecurity |
||
152 | */ |
||
153 | 6 | public function setConfigClosure(Closure $config) |
|
159 | |||
160 | /** |
||
161 | * Updates policy configuration with rules from each profile in given parameters. |
||
162 | * |
||
163 | * @param array $parameters |
||
164 | * |
||
165 | * @return void |
||
166 | */ |
||
167 | 4 | protected function setProfilesWithParameters(array $parameters) |
|
172 | } |
||
173 |