Passed
Push — master ( 5ce155...c96346 )
by meta
02:37
created
src/Controllers/ApiAuthController.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -134,8 +134,8 @@
 block discarded – undo
134 134
         }
135 135
         // Get the X509 certificate for the selected key id
136 136
         $certificate = '-----BEGIN CERTIFICATE-----'.PHP_EOL
137
-                     .$x5c.PHP_EOL
138
-                     .'-----END CERTIFICATE-----';
137
+                        .$x5c.PHP_EOL
138
+                        .'-----END CERTIFICATE-----';
139 139
         // Perform the verification and get the verified payload results
140 140
         $payload = \Firebase\JWT\JWT::decode($accessToken, $certificate, ['RS256']);
141 141
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $app_id = $appData->azp;
101 101
         $app = \Metaclassing\EnterpriseAuth\Models\AzureApp::where('app_id', $app_id)->first();
102 102
         // If we dont have an existing app go create one
103
-        if (! $app) {
103
+        if (!$app) {
104 104
             $azureApp = [
105 105
                 'name'   => $app_id,
106 106
                 'app_id' => $app_id,
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
         // Unpack our jwt to verify it is correctly formed
118 118
         $token = $this->unpackJwt($accessToken);
119 119
         // app tokens must be signed in RSA
120
-        if (! isset($token['header']['alg']) || $token['header']['alg'] != 'RS256') {
120
+        if (!isset($token['header']['alg']) || $token['header']['alg'] != 'RS256') {
121 121
             throw new \Exception('Token is not using the correct signing algorithm RS256 '.$accessToken);
122 122
         }
123 123
         // app tokens are RSA signed with a key ID in the header of the token
124
-        if (! isset($token['header']['kid'])) {
124
+        if (!isset($token['header']['kid'])) {
125 125
             throw new \Exception('Token with unknown RSA key id can not be validated '.$accessToken);
126 126
         }
127 127
         // Make sure the key id is known to our azure ad information
128 128
         $kid = $token['header']['kid'];
129
-        if (! isset($this->azureActiveDirectory->signingKeys[$kid])) {
129
+        if (!isset($this->azureActiveDirectory->signingKeys[$kid])) {
130 130
             throw new \Exception('Token signed with unknown KID '.$kid);
131 131
         }
132 132
         // get the x509 encoded cert body
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         $roles = $user->roles()->get()->all();
204 204
         foreach ($roles as $key => $role) {
205 205
             $role->permissions = $role->abilities()->get()->all();
206
-            if (! count($role->permissions)) {
206
+            if (!count($role->permissions)) {
207 207
                 unset($roles[$key]);
208 208
             }
209 209
         }
Please login to merge, or discard this patch.
src/Controllers/AuthController.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
         $graph = new \Microsoft\Graph\Graph();
41 41
         $graph->setAccessToken($accessToken);
42 42
         $user = $graph->createRequest('GET', '/me')
43
-                      ->setReturnType(\Microsoft\Graph\Model\User::class)
44
-                      ->execute();
43
+                        ->setReturnType(\Microsoft\Graph\Model\User::class)
44
+                        ->execute();
45 45
 
46 46
         return $user->jsonSerialize();
47 47
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         // get the cert from the webserver and load it into an x509 phpseclib object
99 99
         $cert = $this->loadClientCertFromWebserver();
100
-         // extract the UPN from the client cert
100
+            // extract the UPN from the client cert
101 101
         $upn = $this->getUserPrincipalNameFromClientCert($cert);
102 102
         // get the user if it exists
103 103
         $user_class = config('enterpriseauth.user_class');
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
         if (count($groups)) {
164 164
             // remove the users existing database roles before assigning new ones
165 165
             \DB::table('assigned_roles')
166
-               ->where('entity_id', $user->id)
167
-               ->where('entity_type', get_class($user))
168
-               ->delete();
166
+                ->where('entity_id', $user->id)
167
+                ->where('entity_type', get_class($user))
168
+                ->delete();
169 169
             // add the user to each group they are assigned
170 170
             $user->assign($groups);
171 171
         }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function scrubMicrosoftGraphUserData($userData)
50 50
     {
51 51
         // Fix any stupid crap with missing or null fields
52
-        if (! isset($userData['mail']) || ! $userData['mail']) {
52
+        if (!isset($userData['mail']) || !$userData['mail']) {
53 53
             $userData['mail'] = $userData['userPrincipalName'];
54 54
         }
55 55
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         // Try to find an existing user
65 65
         $user = $userType::where($userIdField, $userData['id'])->first();
66 66
         // If we dont have an existing user
67
-        if (! $user) {
67
+        if (!$user) {
68 68
             // Go create a new one with this data
69 69
             $user = $this->createUserFromAzureData($userData);
70 70
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
         // TODO: rewrite this so that if the user doesnt exist we create them and get their groups from AAD
106 106
         $user = $user_class::where('userPrincipalName', $upn)->first();
107
-        if (! $user) {
107
+        if (!$user) {
108 108
             throw new \Exception('No user found with user principal name '.$upn);
109 109
         }
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     public function loadClientCertFromWebserver()
115 115
     {
116 116
         // Make sure we got a client certificate from the web server
117
-        if (! $_SERVER['SSL_CLIENT_CERT']) {
117
+        if (!$_SERVER['SSL_CLIENT_CERT']) {
118 118
             throw new \Exception('TLS client certificate missing');
119 119
         }
120 120
         // try to parse the certificate we got
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     public function getUserPrincipalNameFromClientCert($x509)
129 129
     {
130 130
         $names = $x509->getExtension('id-ce-subjectAltName');
131
-        if (! $names) {
131
+        if (!$names) {
132 132
             throw new \Exception('TLS client cert missing subject alternative names');
133 133
         }
134 134
         // Search subject alt names for user principal name
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                 }
143 143
             }
144 144
         }
145
-        if (! $upn) {
145
+        if (!$upn) {
146 146
             throw new \Exception('Could not find user principal name in TLS client cert');
147 147
         }
148 148
         return $upn;
Please login to merge, or discard this patch.