@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | parent::__construct('twofactorauth:gateway:status'); |
23 | 23 | } |
24 | 24 | |
25 | - #[\Override] |
|
25 | + #[\Override ] |
|
26 | 26 | protected function execute(InputInterface $input, OutputInterface $output) { |
27 | 27 | $fqcn = $this->gatewayFactory->getFqcnList(); |
28 | 28 | foreach ($fqcn as $fqcn) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $gateway = $this->gatewayFactory->get($fqcn::getProviderId()); |
31 | 31 | $isConfigured = $gateway->isComplete(); |
32 | 32 | $settings = $gateway->getSettings(); |
33 | - $output->writeln($settings['name'] . ': ' . ($isConfigured ? 'configured' : 'not configured')); |
|
33 | + $output->writeln($settings[ 'name' ].': '.($isConfigured ? 'configured' : 'not configured')); |
|
34 | 34 | } |
35 | 35 | return 0; |
36 | 36 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Symfony\Component\Console\Question\ChoiceQuestion; |
21 | 21 | |
22 | 22 | class Remove extends Command { |
23 | - private array $ids = []; |
|
23 | + private array $ids = [ ]; |
|
24 | 24 | |
25 | 25 | public function __construct( |
26 | 26 | private Factory $gatewayFactory, |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | |
30 | 30 | $fqcn = $this->gatewayFactory->getFqcnList(); |
31 | 31 | foreach ($fqcn as $fqcn) { |
32 | - $this->ids[] = $fqcn::getProviderId(); |
|
32 | + $this->ids[ ] = $fqcn::getProviderId(); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $this->addArgument( |
36 | 36 | 'gateway', |
37 | 37 | InputArgument::OPTIONAL, |
38 | - 'The name of the gateway: ' . implode(', ', $this->ids) |
|
38 | + 'The name of the gateway: '.implode(', ', $this->ids) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
42 | - #[\Override] |
|
42 | + #[\Override ] |
|
43 | 43 | protected function execute(InputInterface $input, OutputInterface $output) { |
44 | 44 | $gatewayName = strtolower((string)$input->getArgument('gateway')); |
45 | 45 | if (!in_array($gatewayName, $this->ids, true)) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** @var AGateway */ |
53 | 53 | $gateway = $this->gatewayFactory->get($gatewayName); |
54 | 54 | } catch (Exception $e) { |
55 | - $output->writeln('<error>' . $e->getMessage() . '</error>'); |
|
55 | + $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
56 | 56 | return 1; |
57 | 57 | } |
58 | 58 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Symfony\Component\Console\Question\ChoiceQuestion; |
21 | 21 | |
22 | 22 | class Configure extends Command { |
23 | - private array $ids = []; |
|
23 | + private array $ids = [ ]; |
|
24 | 24 | |
25 | 25 | public function __construct( |
26 | 26 | private Factory $gatewayFactory, |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | |
30 | 30 | $fqcn = $this->gatewayFactory->getFqcnList(); |
31 | 31 | foreach ($fqcn as $fqcn) { |
32 | - $this->ids[] = $fqcn::getProviderId(); |
|
32 | + $this->ids[ ] = $fqcn::getProviderId(); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $this->addArgument( |
36 | 36 | 'gateway', |
37 | 37 | InputArgument::OPTIONAL, |
38 | - 'The name of the gateway: ' . implode(', ', $this->ids) |
|
38 | + 'The name of the gateway: '.implode(', ', $this->ids) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
42 | - #[\Override] |
|
42 | + #[\Override ] |
|
43 | 43 | protected function execute(InputInterface $input, OutputInterface $output) { |
44 | 44 | $gatewayName = strtolower((string)$input->getArgument('gateway')); |
45 | 45 | if (!in_array($gatewayName, $this->ids, true)) { |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | * 400: User not found |
44 | 44 | * 503: Gateway wasn't configured yed |
45 | 45 | */ |
46 | - #[NoAdminRequired] |
|
47 | - #[ApiRoute(verb: 'GET', url: '/settings/{gateway}/verification')] |
|
46 | + #[NoAdminRequired ] |
|
47 | + #[ApiRoute(verb: 'GET', url: '/settings/{gateway}/verification') ] |
|
48 | 48 | public function getVerificationState(string $gateway): JSONResponse { |
49 | 49 | $user = $this->userSession->getUser(); |
50 | 50 | |
51 | 51 | if (is_null($user)) { |
52 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
52 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if (!$this->gatewayFactory->get($gateway)->isComplete()) { |
56 | - return new JSONResponse([], Http::STATUS_SERVICE_UNAVAILABLE); |
|
56 | + return new JSONResponse([ ], Http::STATUS_SERVICE_UNAVAILABLE); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return new JSONResponse($this->setup->getState($user, $gateway)->jsonSerialize()); |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | * 200: OK |
71 | 71 | * 400: User not found |
72 | 72 | */ |
73 | - #[NoAdminRequired] |
|
74 | - #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/start')] |
|
73 | + #[NoAdminRequired ] |
|
74 | + #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/start') ] |
|
75 | 75 | public function startVerification(string $gateway, string $identifier): JSONResponse { |
76 | 76 | $user = $this->userSession->getUser(); |
77 | 77 | |
78 | 78 | if (is_null($user)) { |
79 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
79 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | try { |
83 | 83 | $state = $this->setup->startSetup($user, $gateway, $identifier); |
84 | 84 | } catch (VerificationException $e) { |
85 | - return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
85 | + return new JSONResponse([ 'message' => $e->getMessage() ], Http::STATUS_BAD_REQUEST); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return new JSONResponse([ |
@@ -101,22 +101,22 @@ discard block |
||
101 | 101 | * 200: OK |
102 | 102 | * 400: User not found |
103 | 103 | */ |
104 | - #[NoAdminRequired] |
|
105 | - #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/finish')] |
|
104 | + #[NoAdminRequired ] |
|
105 | + #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/finish') ] |
|
106 | 106 | public function finishVerification(string $gateway, string $verificationCode): JSONResponse { |
107 | 107 | $user = $this->userSession->getUser(); |
108 | 108 | |
109 | 109 | if (is_null($user)) { |
110 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
110 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | try { |
114 | 114 | $this->setup->finishSetup($user, $gateway, $verificationCode); |
115 | 115 | } catch (VerificationException) { |
116 | - return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
|
116 | + return new JSONResponse([ ], Http::STATUS_BAD_REQUEST); |
|
117 | 117 | } |
118 | 118 | |
119 | - return new JSONResponse([]); |
|
119 | + return new JSONResponse([ ]); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | * 200: OK |
129 | 129 | * 400: User not found |
130 | 130 | */ |
131 | - #[NoAdminRequired] |
|
132 | - #[ApiRoute(verb: 'DELETE', url: '/settings/{gateway}/verification')] |
|
131 | + #[NoAdminRequired ] |
|
132 | + #[ApiRoute(verb: 'DELETE', url: '/settings/{gateway}/verification') ] |
|
133 | 133 | public function revokeVerification(string $gateway): JSONResponse { |
134 | 134 | $user = $this->userSession->getUser(); |
135 | 135 | |
136 | 136 | if (is_null($user)) { |
137 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
137 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return new JSONResponse($this->setup->disable($user, $gateway)); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | ) { |
23 | 23 | } |
24 | 24 | |
25 | - #[\Override] |
|
25 | + #[\Override ] |
|
26 | 26 | public function getBody(): ITemplate { |
27 | 27 | $template = Server::get(ITemplateManager::class)->getTemplate('twofactor_gateway', 'personal_settings'); |
28 | 28 | $template->assign('gateway', $this->gateway); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | private function buildConfigKey(string $gatewayName, string $key): string { |
30 | - return $gatewayName . "_$key"; |
|
30 | + return $gatewayName."_$key"; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | private function getUserValue(IUser $user, string $gatewayName, string $key, string $default = ''): string { |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * twofactorgateway?: TwoFactorGatewayCapabilities, |
30 | 30 | * } |
31 | 31 | */ |
32 | - #[Override] |
|
32 | + #[Override ] |
|
33 | 33 | public function getCapabilities(): array { |
34 | 34 | $capabilities = [ |
35 | 35 | 'features' => self::FEATURES, |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | public const SCHEMA = [ |
35 | 35 | 'name' => 'OVH', |
36 | 36 | 'fields' => [ |
37 | - ['field' => 'endpoint', 'prompt' => 'Please enter the endpoint (ovh-eu, ovh-us, ovh-ca, soyoustart-eu, soyoustart-ca, kimsufi-eu, kimsufi-ca, runabove-ca):'], |
|
38 | - ['field' => 'application_key', 'prompt' => 'Please enter your application key:'], |
|
39 | - ['field' => 'application_secret','prompt' => 'Please enter your application secret:'], |
|
40 | - ['field' => 'consumer_key', 'prompt' => 'Please enter your consumer key:'], |
|
41 | - ['field' => 'account', 'prompt' => 'Please enter your account (sms-*****):'], |
|
42 | - ['field' => 'sender', 'prompt' => 'Please enter your sender:'], |
|
37 | + [ 'field' => 'endpoint', 'prompt' => 'Please enter the endpoint (ovh-eu, ovh-us, ovh-ca, soyoustart-eu, soyoustart-ca, kimsufi-eu, kimsufi-ca, runabove-ca):' ], |
|
38 | + [ 'field' => 'application_key', 'prompt' => 'Please enter your application key:' ], |
|
39 | + [ 'field' => 'application_secret', 'prompt' => 'Please enter your application secret:' ], |
|
40 | + [ 'field' => 'consumer_key', 'prompt' => 'Please enter your consumer key:' ], |
|
41 | + [ 'field' => 'account', 'prompt' => 'Please enter your account (sms-*****):' ], |
|
42 | + [ 'field' => 'sender', 'prompt' => 'Please enter your sender:' ], |
|
43 | 43 | ], |
44 | 44 | ]; |
45 | 45 | private IClient $client; |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | $this->client = $clientService->newClient(); |
77 | 77 | } |
78 | 78 | |
79 | - #[\Override] |
|
79 | + #[\Override ] |
|
80 | 80 | public function send(string $identifier, string $message) { |
81 | 81 | $endpoint = $this->getEndpoint(); |
82 | 82 | $sender = $this->getSender(); |
83 | 83 | $smsAccount = $this->getAccount(); |
84 | 84 | |
85 | - $this->attrs['AK'] = $this->getApplicationKey(); |
|
86 | - $this->attrs['AS'] = $this->getApplicationSecret(); |
|
87 | - $this->attrs['CK'] = $this->getConsumerKey(); |
|
88 | - if (!isset($this->endpoints[$endpoint])) { |
|
85 | + $this->attrs[ 'AK' ] = $this->getApplicationKey(); |
|
86 | + $this->attrs[ 'AS' ] = $this->getApplicationSecret(); |
|
87 | + $this->attrs[ 'CK' ] = $this->getConsumerKey(); |
|
88 | + if (!isset($this->endpoints[ $endpoint ])) { |
|
89 | 89 | throw new InvalidProviderException("Endpoint $endpoint not found"); |
90 | 90 | } |
91 | - $this->attrs['endpoint'] = $this->endpoints[$endpoint]; |
|
91 | + $this->attrs[ 'endpoint' ] = $this->endpoints[ $endpoint ]; |
|
92 | 92 | |
93 | 93 | $this->getTimeDelta(); |
94 | 94 | |
95 | - $header = $this->getHeader('GET', $this->attrs['endpoint'] . '/sms'); |
|
96 | - $response = $this->client->get($this->attrs['endpoint'] . '/sms', [ |
|
95 | + $header = $this->getHeader('GET', $this->attrs[ 'endpoint' ].'/sms'); |
|
96 | + $response = $this->client->get($this->attrs[ 'endpoint' ].'/sms', [ |
|
97 | 97 | 'headers' => $header, |
98 | 98 | ]); |
99 | 99 | $body = (string)$response->getBody(); |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | ]; |
122 | 122 | $body = json_encode($content); |
123 | 123 | |
124 | - $header = $this->getHeader('POST', $this->attrs['endpoint'] . "/sms/$smsAccount/jobs", $body); |
|
125 | - $response = $this->client->post($this->attrs['endpoint'] . "/sms/$smsAccount/jobs", [ |
|
124 | + $header = $this->getHeader('POST', $this->attrs[ 'endpoint' ]."/sms/$smsAccount/jobs", $body); |
|
125 | + $response = $this->client->post($this->attrs[ 'endpoint' ]."/sms/$smsAccount/jobs", [ |
|
126 | 126 | 'headers' => $header, |
127 | 127 | 'json' => $content, |
128 | 128 | ]); |
129 | 129 | $body = (string)$response->getBody(); |
130 | 130 | $resultPostJob = json_decode($body, true); |
131 | 131 | |
132 | - if (count($resultPostJob['validReceivers']) === 0) { |
|
132 | + if (count($resultPostJob[ 'validReceivers' ]) === 0) { |
|
133 | 133 | throw new MessageTransmissionException("Bad receiver $identifier"); |
134 | 134 | } |
135 | 135 | } |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | * @throws InvalidProviderException |
141 | 141 | */ |
142 | 142 | private function getTimeDelta(): void { |
143 | - if (!isset($this->attrs['timedelta'])) { |
|
144 | - if (!isset($this->attrs['endpoint'])) { |
|
143 | + if (!isset($this->attrs[ 'timedelta' ])) { |
|
144 | + if (!isset($this->attrs[ 'endpoint' ])) { |
|
145 | 145 | throw new InvalidProviderException('Need to set the endpoint'); |
146 | 146 | } |
147 | 147 | try { |
148 | - $response = $this->client->get($this->attrs['endpoint'] . '/auth/time'); |
|
148 | + $response = $this->client->get($this->attrs[ 'endpoint' ].'/auth/time'); |
|
149 | 149 | $serverTimestamp = (int)$response->getBody(); |
150 | - $this->attrs['timedelta'] = $serverTimestamp - time(); |
|
150 | + $this->attrs[ 'timedelta' ] = $serverTimestamp - time(); |
|
151 | 151 | } catch (Exception $ex) { |
152 | - throw new InvalidProviderException('Unable to calculate time delta:' . $ex->getMessage()); |
|
152 | + throw new InvalidProviderException('Unable to calculate time delta:'.$ex->getMessage()); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | * @return array $header Contains the data for the request need by OVH |
163 | 163 | */ |
164 | 164 | private function getHeader($method, $query, $body = '') { |
165 | - $timestamp = time() + $this->attrs['timedelta']; |
|
166 | - $prehash = $this->attrs['AS'] . '+' . $this->attrs['CK'] . '+' . $method . '+' . $query . '+' . $body . '+' . $timestamp; |
|
165 | + $timestamp = time() + $this->attrs[ 'timedelta' ]; |
|
166 | + $prehash = $this->attrs[ 'AS' ].'+'.$this->attrs[ 'CK' ].'+'.$method.'+'.$query.'+'.$body.'+'.$timestamp; |
|
167 | 167 | $header = [ |
168 | 168 | 'Content-Type' => 'application/json; charset=utf-8', |
169 | - 'X-Ovh-Application' => $this->attrs['AK'], |
|
169 | + 'X-Ovh-Application' => $this->attrs[ 'AK' ], |
|
170 | 170 | 'X-Ovh-Timestamp' => $timestamp, |
171 | - 'X-Ovh-Signature' => '$1$' . sha1($prehash), |
|
172 | - 'X-Ovh-Consumer' => $this->attrs['CK'], |
|
171 | + 'X-Ovh-Signature' => '$1$'.sha1($prehash), |
|
172 | + 'X-Ovh-Consumer' => $this->attrs[ 'CK' ], |
|
173 | 173 | ]; |
174 | 174 | return $header; |
175 | 175 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | public const SCHEMA = [ |
28 | 28 | 'name' => 'SerwerSMS', |
29 | 29 | 'fields' => [ |
30 | - ['field' => 'login', 'prompt' => 'Please enter your SerwerSMS.pl API login:'], |
|
31 | - ['field' => 'password', 'prompt' => 'Please enter your SerwerSMS.pl API password:'], |
|
32 | - ['field' => 'sender', 'prompt' => 'Please enter your SerwerSMS.pl sender name:'], |
|
30 | + [ 'field' => 'login', 'prompt' => 'Please enter your SerwerSMS.pl API login:' ], |
|
31 | + [ 'field' => 'password', 'prompt' => 'Please enter your SerwerSMS.pl API password:' ], |
|
32 | + [ 'field' => 'sender', 'prompt' => 'Please enter your SerwerSMS.pl sender name:' ], |
|
33 | 33 | ], |
34 | 34 | ]; |
35 | 35 | private IClient $client; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->client = $clientService->newClient(); |
41 | 41 | } |
42 | 42 | |
43 | - #[\Override] |
|
43 | + #[\Override ] |
|
44 | 44 | public function send(string $identifier, string $message) { |
45 | 45 | $login = $this->getLogin(); |
46 | 46 | $password = $this->getPassword(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $responseData = json_decode((string)$response->getBody(), true); |
63 | 63 | |
64 | - if ($responseData['success'] !== true) { |
|
64 | + if ($responseData[ 'success' ] !== true) { |
|
65 | 65 | throw new MessageTransmissionException(); |
66 | 66 | } |
67 | 67 | } catch (Exception $ex) { |