Passed
Branch psalm (a2980a)
by Tim
03:59
created
lib/Store.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
         }
121 121
 
122 122
         if (!is_array($config)) {
123
-            throw new Exception('Invalid configuration for consent store option: '.var_export($config, true));
123
+            throw new Exception('Invalid configuration for consent store option: ' . var_export($config, true));
124 124
         }
125 125
 
126 126
         if (!array_key_exists(0, $config)) {
Please login to merge, or discard this patch.
www/managetoken.php 1 patch
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@
 block discarded – undo
26 26
     throw new Exception("Attempt to access the token management page unauthenticated.");
27 27
 }
28 28
 switch ($_POST['submit']) {
29
-    case "NEVERMIND":
30
-        Auth\ProcessingChain::resumeProcessing($state);
31
-        break;
32
-    case "DELETE":
33
-        if ($state['FIDO2AuthSuccessful'] == $_POST['credId']) {
34
-            throw new Exception("Attempt to delete the currently used credential despite UI preventing this.");
35
-        }
36
-        $store = $state['webauthn:store'];
37
-        $store->deleteTokenData($_POST['credId']);
38
-        Auth\ProcessingChain::resumeProcessing($state);
39
-        break;
40
-    default:
41
-        throw new Exception("Unknown submit button state.");
29
+        case "NEVERMIND":
30
+            Auth\ProcessingChain::resumeProcessing($state);
31
+            break;
32
+        case "DELETE":
33
+            if ($state['FIDO2AuthSuccessful'] == $_POST['credId']) {
34
+                throw new Exception("Attempt to delete the currently used credential despite UI preventing this.");
35
+            }
36
+            $store = $state['webauthn:store'];
37
+            $store->deleteTokenData($_POST['credId']);
38
+            Auth\ProcessingChain::resumeProcessing($state);
39
+            break;
40
+        default:
41
+            throw new Exception("Unknown submit button state.");
42 42
 }
43 43
 
Please login to merge, or discard this patch.
lib/Auth/Process/WebAuthn.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             $this->store = Store::parseStoreConfig($config['store']);
77 77
         } catch (\Exception $e) {
78 78
             Logger::error(
79
-                'webauthn: Could not create storage: '.
79
+                'webauthn: Could not create storage: ' .
80 80
                 $e->getMessage()
81 81
             );
82 82
         }
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
         assert(array_key_exists('metadata-set', $state['Source']));
133 133
 
134 134
         if (!array_key_exists($this->usernameAttrib, $state['Attributes'])) {
135
-            Logger::warning('webauthn: cannot determine if user needs second factor, missing attribute "'.
136
-                $this->usernameAttrib.'".');
135
+            Logger::warning('webauthn: cannot determine if user needs second factor, missing attribute "' .
136
+                $this->usernameAttrib . '".');
137 137
             return;
138 138
         }
139 139
 
Please login to merge, or discard this patch.
bin/updateMetadata.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once(dirname(dirname(dirname(__DIR__))).'/vendor/autoload.php');
3
+require_once(dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php');
4 4
 
5 5
 use Lcobucci\JWT\Parser;
6 6
 use SimpleSAML\Utils\Config as SSPConfig;
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     );
13 13
 }
14 14
 
15
-$toc = file_get_contents('https://mds2.fidoalliance.org/?token='.$argv[1]);
15
+$toc = file_get_contents('https://mds2.fidoalliance.org/?token=' . $argv[1]);
16 16
 
17 17
 const YUBICO_CA = "MIIDHjCCAgagAwIBAgIEG0BT9zANBgkqhkiG9w0BAQsFADAuMSwwKgYDVQQDEyNZdWJpY28gVTJGIFJvb3QgQ0EgU2VyaWFsIDQ1NzIwMDYzMTAgFw0xNDA4MDEwMDAwMDBaGA8yMDUwMDkwNDAwMDAwMFowLjEsMCoGA1UEAxMjWXViaWNvIFUyRiBSb290IENBIFNlcmlhbCA0NTcyMDA2MzEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC/jwYuhBVlqaiYWEMsrWFisgJ+PtM91eSrpI4TK7U53mwCIawSDHy8vUmk5N2KAj9abvT9NP5SMS1hQi3usxoYGonXQgfO6ZXyUA9a+KAkqdFnBnlyugSeCOep8EdZFfsaRFtMjkwz5Gcz2Py4vIYvCdMHPtwaz0bVuzneueIEz6TnQjE63Rdt2zbwnebwTG5ZybeWSwbzy+BJ34ZHcUhPAY89yJQXuE0IzMZFcEBbPNRbWECRKgjq//qT9nmDOFVlSRCt2wiqPSzluwn+v+suQEBsUjTGMEd25tKXXTkNW21wIWbxeSyUoTXwLvGS6xlwQSgNpk2qXYwf8iXg7VWZAgMBAAGjQjBAMB0GA1UdDgQWBBQgIvz0bNGJhjgpToksyKpP9xv9oDAPBgNVHRMECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAjvjuOMDSa+JXFCLyBKsycXtBVZsJ4Ue3LbaEsPY4MYN/hIQ5ZM5p7EjfcnMG4CtYkNsfNHc0AhBLdq45rnT87q/6O3vUEtNMafbhU6kthX7Y+9XFN9NpmYxr+ekVY5xOxi8h9JDIgoMP4VB1uS0aunL1IGqrNooL9mmFnL2kLVVee6/VR6C5+KSTCMCWppMuJIZII2v9o4dkoZ8Y7QRjQlLfYzd3qGtKbw7xaF1UsG/5xUb/Btwb2X2g4InpiB/yt/3CpQXpiWX/K4mBvUKiGn05ZsqeY1gx4g0xLBqcU9psmyPzK+Vsgw2jeRQ5JlKDyqE0hebfC1tvFu0CCrJFcw==";
18 18
 
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 
21 21
 $res = [];
22 22
 foreach ($token->getClaim('entries') as $oneEntryObject) {
23
-    $thisUrl = $oneEntryObject->url."?token=".$argv[1];
23
+    $thisUrl = $oneEntryObject->url . "?token=" . $argv[1];
24 24
     $mdB64 = file_get_contents($thisUrl);
25 25
     $mdArray = json_decode(base64_decode($mdB64), true);
26 26
     if (isset($mdArray['aaguid']) && isset($mdArray['attestationRootCertificates'][0])) {
27 27
         $compressedAaguid = strtolower(str_replace('-', '', $mdArray['aaguid']));
28 28
         // we need C and O values for the attestation certificates. Extract those from the first root
29
-        $x509 = openssl_x509_parse("-----BEGIN CERTIFICATE-----\n".$mdArray['attestationRootCertificates'][0]."\n-----END CERTIFICATE-----");
29
+        $x509 = openssl_x509_parse("-----BEGIN CERTIFICATE-----\n" . $mdArray['attestationRootCertificates'][0] . "\n-----END CERTIFICATE-----");
30 30
         // print_r($x509);
31 31
         if (isset($x509['subject']['C']) && isset($x509['subject']['O'])) {
32 32
             $res[$compressedAaguid] = [
@@ -91,6 +91,6 @@  discard block
 block discarded – undo
91 91
 ];
92 92
 
93 93
 file_put_contents(
94
-    SSPConfig::getConfigDir().'/'.WebAuthnRegistrationEvent::AAGUID_CONFIG_FILE,
94
+    SSPConfig::getConfigDir() . '/' . WebAuthnRegistrationEvent::AAGUID_CONFIG_FILE,
95 95
     json_encode($res, JSON_PRETTY_PRINT)
96 96
 );
Please login to merge, or discard this patch.
lib/WebAuthn/AAGUID.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected function __construct()
43 43
     {
44
-        $path = SSPConfig::getConfigDir().'/'.self::AAGUID_CONFIG_FILE;
44
+        $path = SSPConfig::getConfigDir() . '/' . self::AAGUID_CONFIG_FILE;
45 45
         if (!file_exists($path)) {
46 46
             Logger::warning('Missing "webauthn_tokens.json" configuration file. No device will be recognized.');
47 47
             return null;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $json = json_decode($data, true);
52 52
         if (!is_array($json)) {
53 53
             // there was probably an error decoding the config, log the error and pray for the best
54
-            Logger::warning('Broken configuration file "'.$path.'": could not JSON-decode it.');
54
+            Logger::warning('Broken configuration file "' . $path . '": could not JSON-decode it.');
55 55
         } else {
56 56
             $this->dictionary = $json;
57 57
         }
Please login to merge, or discard this patch.
www/regprocess.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 
34 34
 $regObject = new WebAuthnRegistrationEvent(
35 35
     $_POST['type'],
36
-    ( $state['FIDO2Scope'] === null ? $state['FIDO2DerivedScope'] : $state['FIDO2Scope'] ),
36
+    ($state['FIDO2Scope'] === null ? $state['FIDO2DerivedScope'] : $state['FIDO2Scope']),
37 37
     $state['FIDO2SignupChallenge'],
38 38
     $state['IdPMetadata']['entityid'],
39 39
     base64_decode($_POST['attestation_object']),
Please login to merge, or discard this patch.
templates/webauthn.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@  discard block
 block discarded – undo
9 9
 
10 10
     <h1><?php echo htmlspecialchars($this->t('{webauthn:webauthn:heading1}')); ?></h1>
11 11
     <h2><?php echo htmlspecialchars($this->t('{webauthn:webauthn:accountEnabled}')); ?></h2>
12
-    <?php if((isset($this->data['FIDO2Tokens'])?((is_array($this->data['FIDO2Tokens']) || $this->data['FIDO2Tokens'] instanceof Countable)?count($this->data['FIDO2Tokens']):strlen($this->data['FIDO2Tokens'])):0) > 0): ?>
12
+    <?php if ((isset($this->data['FIDO2Tokens']) ? ((is_array($this->data['FIDO2Tokens']) || $this->data['FIDO2Tokens'] instanceof Countable) ?count($this->data['FIDO2Tokens']) : strlen($this->data['FIDO2Tokens'])) : 0) > 0) : ?>
13 13
         <div id="currentTokens">
14 14
             <span id='tokencaption'><?php echo htmlspecialchars($this->t('{webauthn:webauthn:tokenList}')); ?></span>
15 15
             <ul>
16
-                <?php foreach($this->data['FIDO2Tokens'] as $index => $this->data['token']): ?>
17
-                    <?php if($this->data['FIDO2AuthSuccessful'] == false or $this->data['FIDO2AuthSuccessful'] != $this->data['token'][0]): ?>
16
+                <?php foreach ($this->data['FIDO2Tokens'] as $index => $this->data['token']): ?>
17
+                    <?php if ($this->data['FIDO2AuthSuccessful'] == false or $this->data['FIDO2AuthSuccessful'] != $this->data['token'][0]): ?>
18 18
                         <li class='othertoken'><?php echo htmlspecialchars($this->data['token'][3]); ?></li>
19 19
                     <?php else: ?>
20 20
                         <li class='currenttoken'><?php echo htmlspecialchars($this->data['token'][3]); ?> <?php echo htmlspecialchars($this->t('{webauthn:webauthn:currentToken}')); ?></li>
21 21
                     <?php endif; ?>
22
-                <?php endforeach;?>
22
+                <?php endforeach; ?>
23 23
             </ul>
24 24
         </div>
25 25
     <?php endif; ?>
26
-    <?php if((isset($this->data['regURL'])?((is_array($this->data['regURL']) || $this->data['regURL'] instanceof Countable)?count($this->data['regURL']):strlen($this->data['regURL'])):0) > 0): ?>
26
+    <?php if ((isset($this->data['regURL']) ? ((is_array($this->data['regURL']) || $this->data['regURL'] instanceof Countable) ?count($this->data['regURL']) : strlen($this->data['regURL'])) : 0) > 0) : ?>
27 27
         <form id='regform' method='POST' action='<?php echo $this->data['regURL']; ?>'>
28 28
             <input type='hidden' id='resp' name='response_id' value='0'/>
29 29
             <input type='hidden' id='data' name='attestation_client_data_json' value='nix'/>
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
                 value='<?php echo htmlspecialchars($this->t('{webauthn:webauthn:newTokenDefaultName}')); ?> <?php echo htmlspecialchars((new DateTime("now"))->format('Y-m-d')); ?>' />
37 37
         </form>
38 38
         <div class='space'></div>
39
-        <?php if((isset($this->data['FIDO2Tokens'])?((is_array($this->data['FIDO2Tokens']) || $this->data['FIDO2Tokens'] instanceof Countable)?count($this->data['FIDO2Tokens']):strlen($this->data['FIDO2Tokens'])):0) > 0): ?>
40
-            <?php foreach($this->data['FIDO2Tokens'] as $index => $this->data['token']): ?>
41
-                <?php if($this->data['FIDO2AuthSuccessful'] != $this->data['token'][0]): ?>
39
+        <?php if ((isset($this->data['FIDO2Tokens']) ? ((is_array($this->data['FIDO2Tokens']) || $this->data['FIDO2Tokens'] instanceof Countable) ?count($this->data['FIDO2Tokens']) : strlen($this->data['FIDO2Tokens'])) : 0) > 0) : ?>
40
+            <?php foreach ($this->data['FIDO2Tokens'] as $index => $this->data['token']): ?>
41
+                <?php if ($this->data['FIDO2AuthSuccessful'] != $this->data['token'][0]): ?>
42 42
                     <form class='deleteform' id='delete-<?php echo htmlspecialchars($index); ?>' method='POST' action='<?php echo $this->data['delURL']; ?>'>
43 43
                         <input type='hidden' id='credId-<?php echo htmlspecialchars($index); ?>' name='credId' value='<?php echo htmlspecialchars($this->data['token'][0]); ?>'/>
44 44
                         <button type='submit' id='submit-<?php echo htmlspecialchars($index); ?>' name='submit' value='DELETE'>
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                         </button>
47 47
                     </form>
48 48
                 <?php endif; ?>
49
-            <?php endforeach;?>
49
+            <?php endforeach; ?>
50 50
             <div class='space'></div>
51 51
             <form id='nevermind' method='POST' action='<?php echo $this->data['delURL']; ?>'>
52 52
                 <button type='submit' id='submit-nevermind' name='submit' value='NEVERMIND'>
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             </form>
56 56
         <?php endif; ?>
57 57
     <?php endif; ?>
58
-    <?php if((isset($this->data['authURL'])?((is_array($this->data['authURL']) || $this->data['authURL'] instanceof Countable)?count($this->data['authURL']):strlen($this->data['authURL'])):0) > 0): ?>
58
+    <?php if ((isset($this->data['authURL']) ? ((is_array($this->data['authURL']) || $this->data['authURL'] instanceof Countable) ?count($this->data['authURL']) : strlen($this->data['authURL'])) : 0) > 0) : ?>
59 59
         <form id='authform' method='POST' action='<?php echo $this->data['authURL']; ?>'>
60 60
             <input type='hidden' id='resp' name='response_id' value='0'/>
61 61
             <input type='hidden' id='data_raw_b64' name='client_data_raw' value='garnix'/>
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             <input type='hidden' id='operation' name='operation' value='AUTH'/>
68 68
             <input type='checkbox' id='credentialChange' name='credentialChange'>
69 69
             <label for='credentialChange'>
70
-                <?php if((isset($this->data['FIDO2Tokens'])?((is_array($this->data['FIDO2Tokens']) || $this->data['FIDO2Tokens'] instanceof Countable)?count($this->data['FIDO2Tokens']):strlen($this->data['FIDO2Tokens'])):0) < 2): ?>
70
+                <?php if ((isset($this->data['FIDO2Tokens']) ? ((is_array($this->data['FIDO2Tokens']) || $this->data['FIDO2Tokens'] instanceof Countable) ?count($this->data['FIDO2Tokens']) : strlen($this->data['FIDO2Tokens'])) : 0) < 2) : ?>
71 71
                     <?php echo htmlspecialchars($this->t('{webauthn:webauthn:wantsAdd}')); ?>
72 72
                 <?php else: ?>
73 73
                     <?php echo htmlspecialchars($this->t('{webauthn:webauthn:wantsModification}')); ?>
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,8 +16,11 @@  discard block
 block discarded – undo
16 16
                 <?php foreach($this->data['FIDO2Tokens'] as $index => $this->data['token']): ?>
17 17
                     <?php if($this->data['FIDO2AuthSuccessful'] == false or $this->data['FIDO2AuthSuccessful'] != $this->data['token'][0]): ?>
18 18
                         <li class='othertoken'><?php echo htmlspecialchars($this->data['token'][3]); ?></li>
19
-                    <?php else: ?>
20
-                        <li class='currenttoken'><?php echo htmlspecialchars($this->data['token'][3]); ?> <?php echo htmlspecialchars($this->t('{webauthn:webauthn:currentToken}')); ?></li>
19
+                    <?php else {
20
+    : ?>
21
+                        <li class='currenttoken'><?php echo htmlspecialchars($this->data['token'][3]);
22
+}
23
+?> <?php echo htmlspecialchars($this->t('{webauthn:webauthn:currentToken}')); ?></li>
21 24
                     <?php endif; ?>
22 25
                 <?php endforeach;?>
23 26
             </ul>
@@ -69,8 +72,11 @@  discard block
 block discarded – undo
69 72
             <label for='credentialChange'>
70 73
                 <?php if((isset($this->data['FIDO2Tokens'])?((is_array($this->data['FIDO2Tokens']) || $this->data['FIDO2Tokens'] instanceof Countable)?count($this->data['FIDO2Tokens']):strlen($this->data['FIDO2Tokens'])):0) < 2): ?>
71 74
                     <?php echo htmlspecialchars($this->t('{webauthn:webauthn:wantsAdd}')); ?>
72
-                <?php else: ?>
73
-                    <?php echo htmlspecialchars($this->t('{webauthn:webauthn:wantsModification}')); ?>
75
+                <?php else {
76
+    : ?>
77
+                    <?php echo htmlspecialchars($this->t('{webauthn:webauthn:wantsModification}'));
78
+}
79
+?>
74 80
                 <?php endif; ?>
75 81
             </label><br/>
76 82
             <button type='button' id='authformSubmit'><?php echo htmlspecialchars($this->t('{webauthn:webauthn:authTokenButton}')); ?></button>
Please login to merge, or discard this patch.
www/authprocess.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 $authObject = new WebAuthnAuthenticationEvent(
49 49
     $_POST['type'],
50
-    ( $state['FIDO2Scope'] === null ? $state['FIDO2DerivedScope'] : $state['FIDO2Scope'] ), 
50
+    ($state['FIDO2Scope'] === null ? $state['FIDO2DerivedScope'] : $state['FIDO2Scope']), 
51 51
     $state['FIDO2SignupChallenge'], 
52 52
     $state['IdPMetadata']['entityid'], 
53 53
     base64_decode($_POST['authenticator_data']), 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 if ($debugEnabled) {
82 82
     echo $authObject->getDebugBuffer();
83 83
     echo $authObject->getValidateBuffer();
84
-    echo "Debug mode, not continuing to ". ($state['FIDO2WantsRegister'] ? "credential registration page." : "destination.");
84
+    echo "Debug mode, not continuing to " . ($state['FIDO2WantsRegister'] ? "credential registration page." : "destination.");
85 85
 } else {
86 86
     if ($state['FIDO2WantsRegister']) {
87
-        header("Location: ".Module::getModuleURL('webauthn/webauthn.php?StateId='.urlencode($id)));
87
+        header("Location: " . Module::getModuleURL('webauthn/webauthn.php?StateId=' . urlencode($id)));
88 88
     } else {
89 89
         Auth\ProcessingChain::resumeProcessing($state);
90 90
     }
Please login to merge, or discard this patch.
www/webauthn.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleSAML\Logger;
14 14
 use SimpleSAML\Module;
15 15
 use SimpleSAML\Utils;
16
-use SimpleSAML\XHTML\Template;;
16
+use SimpleSAML\XHTML\Template; ;
17 17
 use Webmozart\Assert\Assert;
18 18
 
19 19
 $globalConfig = Configuration::getInstance();
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 $frontendData = [];
62 62
 $frontendData['challengeEncoded'] = $challengeEncoded;
63 63
 $frontendData['state'] = [];
64
-foreach (['Source','FIDO2Scope','FIDO2Username','FIDO2Displayname','requestTokenModel'] as $stateItem) {
64
+foreach (['Source', 'FIDO2Scope', 'FIDO2Username', 'FIDO2Displayname', 'requestTokenModel'] as $stateItem) {
65 65
     Assert::isArray($state[$stateItem]);
66 66
     $frontendData['state'][$stateItem] = $state[$stateItem];
67 67
 }
Please login to merge, or discard this patch.