@@ -37,6 +37,5 @@ |
||
37 | 37 | * @class InvalidAlgorithmException |
38 | 38 | * @package Platine\Framework\Security\JWT\Exception |
39 | 39 | */ |
40 | -class InvalidAlgorithmException extends JWTException |
|
41 | -{ |
|
40 | +class InvalidAlgorithmException extends JWTException { |
|
42 | 41 | } |
@@ -37,6 +37,5 @@ |
||
37 | 37 | * @class InvalidTokenException |
38 | 38 | * @package Platine\Framework\Security\JWT\Exception |
39 | 39 | */ |
40 | -class InvalidTokenException extends JWTException |
|
41 | -{ |
|
40 | +class InvalidTokenException extends JWTException { |
|
42 | 41 | } |
@@ -39,6 +39,5 @@ |
||
39 | 39 | * @class JWTException |
40 | 40 | * @package Platine\Framework\Security\JWT\Exception |
41 | 41 | */ |
42 | -class JWTException extends Exception |
|
43 | -{ |
|
42 | +class JWTException extends Exception { |
|
44 | 43 | } |
@@ -37,6 +37,5 @@ |
||
37 | 37 | * @class TokenExpiredException |
38 | 38 | * @package Platine\Framework\Security\JWT\Exception |
39 | 39 | */ |
40 | -class TokenExpiredException extends JWTException |
|
41 | -{ |
|
40 | +class TokenExpiredException extends JWTException { |
|
42 | 41 | } |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | * @package Platine\Framework\Security\JWT\Signer |
57 | 57 | * @template T |
58 | 58 | */ |
59 | -class HMAC implements SignerInterface |
|
60 | -{ |
|
59 | +class HMAC implements SignerInterface { |
|
61 | 60 | /** |
62 | 61 | * The configuration instance |
63 | 62 | * @var Config<T> |
@@ -74,11 +73,10 @@ discard block |
||
74 | 73 | * Create new instance |
75 | 74 | * @param Config<T> $config |
76 | 75 | */ |
77 | - public function __construct(Config $config) |
|
78 | - { |
|
76 | + public function __construct(Config $config) { |
|
79 | 77 | $this->config = $config; |
80 | 78 | $algo = $config->get('api.sign.hmac.signature_algo', ''); |
81 | - if (!in_array($algo, hash_hmac_algos())) { |
|
79 | + if (!in_array($algo, hash_hmac_algos())) { |
|
82 | 80 | throw new InvalidAlgorithmException(sprintf( |
83 | 81 | 'Invalid HMAC algorithm [%s]', |
84 | 82 | $algo |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class SignerInterface |
52 | 52 | * @package Platine\Framework\Security\JWT |
53 | 53 | */ |
54 | -interface SignerInterface |
|
55 | -{ |
|
54 | +interface SignerInterface { |
|
56 | 55 | /** |
57 | 56 | * Sign the given data using the given key |
58 | 57 | * @param string $data |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | return []; |
207 | 207 | } |
208 | 208 | |
209 | - $policy = new FeaturePermissionPolicy($config); |
|
209 | + $policy = new FeaturePermissionPolicy($config); |
|
210 | 210 | |
211 | 211 | return ['Permissions-Policy' => $policy->headers()]; |
212 | 212 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | return []; |
224 | 224 | } |
225 | 225 | |
226 | - $policy = new StrictTransportSecurityPolicy($config); |
|
226 | + $policy = new StrictTransportSecurityPolicy($config); |
|
227 | 227 | |
228 | 228 | return ['Strict-Transport-Security' => $policy->headers()]; |
229 | 229 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | return []; |
242 | 242 | } |
243 | 243 | |
244 | - $policy = new ClearSiteDataPolicy($config); |
|
244 | + $policy = new ClearSiteDataPolicy($config); |
|
245 | 245 | |
246 | 246 | return ['Clear-Site-Data' => $policy->headers()]; |
247 | 247 | } |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | * @package Platine\Framework\Security |
62 | 62 | * @template T |
63 | 63 | */ |
64 | -class SecurityPolicy |
|
65 | -{ |
|
64 | +class SecurityPolicy { |
|
66 | 65 | /** |
67 | 66 | * The application configuration |
68 | 67 | * @var Config<T> |
@@ -101,7 +100,7 @@ discard block |
||
101 | 100 | Config $config, |
102 | 101 | Router $router, |
103 | 102 | array $configurations = [] |
104 | - ) { |
|
103 | + ) { |
|
105 | 104 | $this->config = $config; |
106 | 105 | $this->router = $router; |
107 | 106 | $this->configurations = $configurations; |
@@ -145,18 +144,18 @@ discard block |
||
145 | 144 | { |
146 | 145 | $config = $this->configurations['csp'] ?? []; |
147 | 146 | $isEnabled = $config['enable'] ?? false; |
148 | - if ($isEnabled === false) { |
|
147 | + if ($isEnabled === false) { |
|
149 | 148 | return []; |
150 | 149 | } |
151 | 150 | |
152 | 151 | $config['script-src']['nonces'] = $this->nonces['script']; |
153 | 152 | $config['style-src']['nonces'] = $this->nonces['style']; |
154 | 153 | |
155 | - if (count($config['report-uri'] ?? []) > 0) { |
|
154 | + if (count($config['report-uri'] ?? []) > 0) { |
|
156 | 155 | $routes = $this->router->routes(); |
157 | 156 | $reportUri = []; |
158 | - foreach ($config['report-uri'] as $url) { |
|
159 | - if ($routes->has($url)) { |
|
157 | + foreach ($config['report-uri'] as $url) { |
|
158 | + if ($routes->has($url)) { |
|
160 | 159 | $url = $this->config->get('app.host') . $this->router->getUri($url)->getPath(); |
161 | 160 | } |
162 | 161 | |
@@ -176,13 +175,13 @@ discard block |
||
176 | 175 | $headers = [$header => $policy->headers()]; |
177 | 176 | |
178 | 177 | $reportTo = []; |
179 | - if ($config['report-to'] ?? false) { |
|
180 | - if (count($config['report-uri'] ?? []) > 0) { |
|
178 | + if ($config['report-to'] ?? false) { |
|
179 | + if (count($config['report-uri'] ?? []) > 0) { |
|
181 | 180 | $reportTo['group'] = $config['report-to']; |
182 | 181 | $reportTo['max_age'] = 1800; // TODO use configuration |
183 | 182 | |
184 | 183 | $reportTo['endpoints'] = []; |
185 | - foreach ($config['report-uri'] as $url) { |
|
184 | + foreach ($config['report-uri'] as $url) { |
|
186 | 185 | $reportTo['endpoints'][] = [ |
187 | 186 | 'url' => $url |
188 | 187 | ]; |
@@ -202,7 +201,7 @@ discard block |
||
202 | 201 | { |
203 | 202 | $config = $this->configurations['features-permissions'] ?? []; |
204 | 203 | $isEnabled = $config['enable'] ?? false; |
205 | - if ($isEnabled === false) { |
|
204 | + if ($isEnabled === false) { |
|
206 | 205 | return []; |
207 | 206 | } |
208 | 207 | |
@@ -219,7 +218,7 @@ discard block |
||
219 | 218 | { |
220 | 219 | $config = $this->configurations['hsts'] ?? []; |
221 | 220 | $isEnabled = $config['enable'] ?? false; |
222 | - if ($isEnabled === false) { |
|
221 | + if ($isEnabled === false) { |
|
223 | 222 | return []; |
224 | 223 | } |
225 | 224 | |
@@ -237,7 +236,7 @@ discard block |
||
237 | 236 | { |
238 | 237 | $config = $this->configurations['clear-site-data'] ?? []; |
239 | 238 | $isEnabled = $config['enable'] ?? false; |
240 | - if ($isEnabled === false) { |
|
239 | + if ($isEnabled === false) { |
|
241 | 240 | return []; |
242 | 241 | } |
243 | 242 |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class CsrfStorageInterface |
52 | 52 | * @package Platine\Framework\Security\Csrf |
53 | 53 | */ |
54 | -interface CsrfStorageInterface |
|
55 | -{ |
|
54 | +interface CsrfStorageInterface { |
|
56 | 55 | /** |
57 | 56 | * Return the token information from storage |
58 | 57 | * @param string $name |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class CsrfUserSessionStorage |
52 | 52 | * @package Platine\Framework\Security\Csrf\Storage |
53 | 53 | */ |
54 | -class CsrfUserSessionStorage extends CsrfSessionStorage |
|
55 | -{ |
|
54 | +class CsrfUserSessionStorage extends CsrfSessionStorage { |
|
56 | 55 | /** |
57 | 56 | * {@inheritdoc} |
58 | 57 | */ |