1 | <?php namespace Stevenmaguire\Laravel\Http\Middleware; |
||
9 | class EnforceContentSecurity extends BaseMiddleware |
||
10 | { |
||
11 | /** |
||
12 | * Config closure; |
||
13 | * |
||
14 | * @var Closure |
||
15 | */ |
||
16 | protected $config; |
||
17 | |||
18 | /** |
||
19 | * Creates new middleware instance. |
||
20 | */ |
||
21 | 6 | public function __construct() |
|
33 | |||
34 | /** |
||
35 | * Handles an incoming request. |
||
36 | * |
||
37 | * @param \Illuminate\Http\Request $request |
||
38 | * @param \Closure $next |
||
39 | * @return mixed |
||
40 | */ |
||
41 | 6 | public function handle($request, Closure $next) |
|
59 | |||
60 | /** |
||
61 | * Creates Laravel response object from PSR 7 response. |
||
62 | * |
||
63 | * @param ResponseInterface $response |
||
64 | * |
||
65 | * @return Response |
||
66 | */ |
||
67 | 4 | protected function createLaravelResponse(ResponseInterface $response) |
|
75 | |||
76 | /** |
||
77 | * Creates PSR 7 response object from Laravel response. |
||
78 | * |
||
79 | * @param Response $response |
||
80 | * |
||
81 | * @return ResponseInterface |
||
82 | */ |
||
83 | 4 | protected function createPsr7Response(Response $response) |
|
92 | |||
93 | /** |
||
94 | * Retrives profile configuration from Laravel config object. |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | 4 | protected function getProfileConfig() |
|
109 | |||
110 | /** |
||
111 | * Retrieves configuration key associated with content security profiles. |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | 4 | protected function getProfileConfigKey() |
|
119 | |||
120 | /** |
||
121 | * Gets profiles from handle method arguments. |
||
122 | * |
||
123 | * @param array $arguments |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | 4 | protected function getProfilesFromArguments(array $arguments) |
|
137 | |||
138 | /** |
||
139 | * Updates config callable used to access application configuration data. |
||
140 | * |
||
141 | * @param Closure $config |
||
142 | * |
||
143 | * @return EnforceContentSecurity |
||
144 | */ |
||
145 | 6 | public function setConfigClosure(Closure $config) |
|
151 | |||
152 | /** |
||
153 | * Updates policy configuration with rules from each profile in given parameters. |
||
154 | * |
||
155 | * @param array $parameters |
||
156 | * |
||
157 | * @return void |
||
158 | */ |
||
159 | 4 | protected function setProfilesWithParameters(array $parameters) |
|
164 | } |
||
165 |