{"action":"created","comment":{"url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/comments/27127870","id":27127870,"diff_hunk":"@@ -235,24 +238,74 @@ public function verifyEmail($verificationNonce)\n         $secondFactorToVerify->verifyEmail();\n     }\n \n-    public function vetSecondFactor($registrationCode, $secondFactorIdentifier, $documentNumber, $identityVerified)\n-    {\n-        foreach ($this->verifiedSecondFactors as $secondFactor) {\n-            if (!$secondFactor->wouldBeVettedBy(\n-                $registrationCode,\n-                $secondFactorIdentifier,\n-                $documentNumber,\n-                $identityVerified\n-            )) {\n-                continue;\n-            }\n+    public function vetSecondFactor(\n+        IdentityApi $identity,\n+        SecondFactorId $secondFactorId,\n+        $secondFactorIdentifier,\n+        $registrationCode,\n+        $documentNumber,\n+        $identityVerified\n+    ) {\n+        /** @var VettedSecondFactor|false $secondFactorWithHighestLoa */\n+        $secondFactorWithHighestLoa = array_reduce(\n+            $this->vettedSecondFactors->toArray(),\n+            function (VettedSecondFactor $carry, VettedSecondFactor $item) {\n+                return $carry->hasEqualOrHigherLoaComparedTo($item) ? $carry : $item;\n+            },\n+            $this->vettedSecondFactors->first()\n+        );\n \n-            $secondFactor->vet($registrationCode, $secondFactorIdentifier, $documentNumber, $identityVerified);\n-            return;\n+        $verifiedSecondFactorHasEqualOrLowerLoaComparedTo =\n+            $identity->verifiedSecondFactorHasEqualOrLowerLoaComparedTo(\n+                $secondFactorId,\n+                $secondFactorWithHighestLoa\n+            );\n+\n+        if (!$verifiedSecondFactorHasEqualOrLowerLoaComparedTo) {\n+            throw new DomainException('Authority does not have the required LoA to vet the identity\\'s second factor');\n+        }","path":"src/Surfnet/Stepup/Identity/Identity.php","position":59,"original_position":59,"commit_id":"9f55c50c6b830f1683d2eff885fb8b58816c08b2","original_commit_id":"9f55c50c6b830f1683d2eff885fb8b58816c08b2","user":{"login":"DRvanR","id":1422284,"avatar_url":"https://avatars.githubusercontent.com/u/1422284?v=3","gravatar_id":"","url":"https://api.github.com/users/DRvanR","html_url":"https://github.com/DRvanR","followers_url":"https://api.github.com/users/DRvanR/followers","following_url":"https://api.github.com/users/DRvanR/following{/other_user}","gists_url":"https://api.github.com/users/DRvanR/gists{/gist_id}","starred_url":"https://api.github.com/users/DRvanR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DRvanR/subscriptions","organizations_url":"https://api.github.com/users/DRvanR/orgs","repos_url":"https://api.github.com/users/DRvanR/repos","events_url":"https://api.github.com/users/DRvanR/events{/privacy}","received_events_url":"https://api.github.com/users/DRvanR/received_events","type":"User","site_admin":false},"body":"Fair enough, good arguments :+1: ","created_at":"2015-03-25T14:54:18Z","updated_at":"2015-03-25T14:54:18Z","html_url":"https://github.com/SURFnet/Stepup-Middleware/pull/61#discussion_r27127870","pull_request_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61","_links":{"self":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/comments/27127870"},"html":{"href":"https://github.com/SURFnet/Stepup-Middleware/pull/61#discussion_r27127870"},"pull_request":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61"}}},"pull_request":{"url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61","id":31850751,"html_url":"https://github.com/SURFnet/Stepup-Middleware/pull/61","diff_url":"https://github.com/SURFnet/Stepup-Middleware/pull/61.diff","patch_url":"https://github.com/SURFnet/Stepup-Middleware/pull/61.patch","issue_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/61","number":61,"state":"open","locked":false,"title":"Let authorities vet identities and only in case of sufficient LoA","user":{"login":"rjkip","id":1734555,"avatar_url":"https://avatars.githubusercontent.com/u/1734555?v=3","gravatar_id":"","url":"https://api.github.com/users/rjkip","html_url":"https://github.com/rjkip","followers_url":"https://api.github.com/users/rjkip/followers","following_url":"https://api.github.com/users/rjkip/following{/other_user}","gists_url":"https://api.github.com/users/rjkip/gists{/gist_id}","starred_url":"https://api.github.com/users/rjkip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjkip/subscriptions","organizations_url":"https://api.github.com/users/rjkip/orgs","repos_url":"https://api.github.com/users/rjkip/repos","events_url":"https://api.github.com/users/rjkip/events{/privacy}","received_events_url":"https://api.github.com/users/rjkip/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-24T17:34:56Z","updated_at":"2015-03-25T14:54:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8bc05bc22282b23b760d4c24556c518f9760c9f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61/commits","review_comments_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61/comments","review_comment_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/61/comments","statuses_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/statuses/9f55c50c6b830f1683d2eff885fb8b58816c08b2","head":{"label":"SURFnet:feature/vetting-min-loa","ref":"feature/vetting-min-loa","sha":"9f55c50c6b830f1683d2eff885fb8b58816c08b2","user":{"login":"SURFnet","id":1485353,"avatar_url":"https://avatars.githubusercontent.com/u/1485353?v=3","gravatar_id":"","url":"https://api.github.com/users/SURFnet","html_url":"https://github.com/SURFnet","followers_url":"https://api.github.com/users/SURFnet/followers","following_url":"https://api.github.com/users/SURFnet/following{/other_user}","gists_url":"https://api.github.com/users/SURFnet/gists{/gist_id}","starred_url":"https://api.github.com/users/SURFnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SURFnet/subscriptions","organizations_url":"https://api.github.com/users/SURFnet/orgs","repos_url":"https://api.github.com/users/SURFnet/repos","events_url":"https://api.github.com/users/SURFnet/events{/privacy}","received_events_url":"https://api.github.com/users/SURFnet/received_events","type":"Organization","site_admin":false},"repo":{"id":23867318,"name":"Stepup-Middleware","full_name":"SURFnet/Stepup-Middleware","owner":{"login":"SURFnet","id":1485353,"avatar_url":"https://avatars.githubusercontent.com/u/1485353?v=3","gravatar_id":"","url":"https://api.github.com/users/SURFnet","html_url":"https://github.com/SURFnet","followers_url":"https://api.github.com/users/SURFnet/followers","following_url":"https://api.github.com/users/SURFnet/following{/other_user}","gists_url":"https://api.github.com/users/SURFnet/gists{/gist_id}","starred_url":"https://api.github.com/users/SURFnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SURFnet/subscriptions","organizations_url":"https://api.github.com/users/SURFnet/orgs","repos_url":"https://api.github.com/users/SURFnet/repos","events_url":"https://api.github.com/users/SURFnet/events{/privacy}","received_events_url":"https://api.github.com/users/SURFnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SURFnet/Stepup-Middleware","description":"","fork":false,"url":"https://api.github.com/repos/SURFnet/Stepup-Middleware","forks_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/forks","keys_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/teams","hooks_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/hooks","issue_events_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/events{/number}","events_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/events","assignees_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/assignees{/user}","branches_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/branches{/branch}","tags_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/tags","blobs_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/refs{/sha}","trees_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/statuses/{sha}","languages_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/languages","stargazers_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/stargazers","contributors_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/contributors","subscribers_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/subscribers","subscription_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/subscription","commits_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/commits{/sha}","git_commits_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/commits{/sha}","comments_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/comments{/number}","issue_comment_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/comments{/number}","contents_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/contents/{+path}","compare_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/merges","archive_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/downloads","issues_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues{/number}","pulls_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls{/number}","milestones_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/milestones{/number}","notifications_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/labels{/name}","releases_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/releases{/id}","created_at":"2014-09-10T08:47:14Z","updated_at":"2015-03-25T12:21:43Z","pushed_at":"2015-03-25T12:21:45Z","git_url":"git://github.com/SURFnet/Stepup-Middleware.git","ssh_url":"git@github.com:SURFnet/Stepup-Middleware.git","clone_url":"https://github.com/SURFnet/Stepup-Middleware.git","svn_url":"https://github.com/SURFnet/Stepup-Middleware","homepage":null,"size":2706,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"develop"}},"base":{"label":"SURFnet:develop","ref":"develop","sha":"bdcb22afc0e1ea4fa671e2d16fd142f2c0e35d3b","user":{"login":"SURFnet","id":1485353,"avatar_url":"https://avatars.githubusercontent.com/u/1485353?v=3","gravatar_id":"","url":"https://api.github.com/users/SURFnet","html_url":"https://github.com/SURFnet","followers_url":"https://api.github.com/users/SURFnet/followers","following_url":"https://api.github.com/users/SURFnet/following{/other_user}","gists_url":"https://api.github.com/users/SURFnet/gists{/gist_id}","starred_url":"https://api.github.com/users/SURFnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SURFnet/subscriptions","organizations_url":"https://api.github.com/users/SURFnet/orgs","repos_url":"https://api.github.com/users/SURFnet/repos","events_url":"https://api.github.com/users/SURFnet/events{/privacy}","received_events_url":"https://api.github.com/users/SURFnet/received_events","type":"Organization","site_admin":false},"repo":{"id":23867318,"name":"Stepup-Middleware","full_name":"SURFnet/Stepup-Middleware","owner":{"login":"SURFnet","id":1485353,"avatar_url":"https://avatars.githubusercontent.com/u/1485353?v=3","gravatar_id":"","url":"https://api.github.com/users/SURFnet","html_url":"https://github.com/SURFnet","followers_url":"https://api.github.com/users/SURFnet/followers","following_url":"https://api.github.com/users/SURFnet/following{/other_user}","gists_url":"https://api.github.com/users/SURFnet/gists{/gist_id}","starred_url":"https://api.github.com/users/SURFnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SURFnet/subscriptions","organizations_url":"https://api.github.com/users/SURFnet/orgs","repos_url":"https://api.github.com/users/SURFnet/repos","events_url":"https://api.github.com/users/SURFnet/events{/privacy}","received_events_url":"https://api.github.com/users/SURFnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SURFnet/Stepup-Middleware","description":"","fork":false,"url":"https://api.github.com/repos/SURFnet/Stepup-Middleware","forks_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/forks","keys_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/teams","hooks_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/hooks","issue_events_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/events{/number}","events_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/events","assignees_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/assignees{/user}","branches_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/branches{/branch}","tags_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/tags","blobs_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/refs{/sha}","trees_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/statuses/{sha}","languages_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/languages","stargazers_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/stargazers","contributors_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/contributors","subscribers_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/subscribers","subscription_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/subscription","commits_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/commits{/sha}","git_commits_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/git/commits{/sha}","comments_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/comments{/number}","issue_comment_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/comments{/number}","contents_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/contents/{+path}","compare_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/merges","archive_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/downloads","issues_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues{/number}","pulls_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls{/number}","milestones_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/milestones{/number}","notifications_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/labels{/name}","releases_url":"https://api.github.com/repos/SURFnet/Stepup-Middleware/releases{/id}","created_at":"2014-09-10T08:47:14Z","updated_at":"2015-03-25T12:21:43Z","pushed_at":"2015-03-25T12:21:45Z","git_url":"git://github.com/SURFnet/Stepup-Middleware.git","ssh_url":"git@github.com:SURFnet/Stepup-Middleware.git","clone_url":"https://github.com/SURFnet/Stepup-Middleware.git","svn_url":"https://github.com/SURFnet/Stepup-Middleware","homepage":null,"size":2706,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61"},"html":{"href":"https://github.com/SURFnet/Stepup-Middleware/pull/61"},"issue":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/61"},"comments":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/issues/61/comments"},"review_comments":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61/comments"},"review_comment":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/pulls/61/commits"},"statuses":{"href":"https://api.github.com/repos/SURFnet/Stepup-Middleware/statuses/9f55c50c6b830f1683d2eff885fb8b58816c08b2"}}}}