{"action":"created","comment":{"url":"https://api.github.com/repos/inverse-inc/packetfence/pulls/comments/24990349","id":24990349,"diff_hunk":"@@ -392,53 +401,42 @@ sub getNormalVlan {\n     # the role based on the rules defined in the different authentication sources.\n     # FIRST HIT MATCH\n     elsif ( defined $user_name && $connection_type && ($connection_type & $EAP) == $EAP ) {\n-        $logger->debug(\"[$mac] EAP connection with a username \\\"$user_name\\\". Trying to match rules from authentication sources.\");\n-        my @sources = ($profile->getInternalSources, $profile->getExclusiveSources );\n-        my $stripped_user = '';\n-        $stripped_user = $stripped_user_name if(defined($stripped_user_name));\n-        my $params = {\n-            username => $user_name,\n-            connection_type => connection_type_to_str($connection_type),\n-            SSID => $ssid,\n-            stripped_user_name => $stripped_user,\n-        };\n-        my $source;\n-        $role = &pf::authentication::match([@sources], $params, $Actions::SET_ROLE, \\$source);\n-        #Compute autoreg if we use autoreg\n-        if (isenabled($node_info->{'autoreg'})) {\n-            my $value = &pf::authentication::match([@sources], $params, $Actions::SET_ACCESS_DURATION);\n-            if (defined $value) {\n-                $logger->trace(\"No unregdate found - computing it from access duration\");\n-                $value = access_duration($value);\n-            }\n-            else {\n-                $value = &pf::authentication::match([@sources], $params, $Actions::SET_UNREG_DATE);\n+        # Attributes has been computed in getNodeInfoForAutoReg\n+        if ((isenabled($node_info->{'autoreg'}) && $autoreg) || !(isenabled($profile->dot1xRecomputeRoleFromPortal))) {\n+            $logger->info(\"[$mac] Connection type is EAP. Getting role from node_info\" );\n+            $role = $node_info->{'category'};\n+        } else {\n+            my @sources = ($profile->getInternalSources, $profile->getExclusiveSources );\n+            my $stripped_user = '';\n+            $stripped_user = $stripped_user_name if(defined($stripped_user_name));\n+            my $params = {\n+                username => $user_name,\n+                connection_type => connection_type_to_str($connection_type),\n+                SSID => $ssid,\n+                stripped_user_name => $stripped_user,\n+            };\n+            my $source;\n+            $role = &pf::authentication::match([@sources], $params, $Actions::SET_ROLE, \\$source);\n+            # create a person entry for pid if it doesn't exist\n+            if ( !pf::person::person_exist($user_name) ) {\n+                $logger->info(\"creating person $user_name because it doesn't exist\");\n+                pf::person::person_add($user_name);\n+                pf::lookup::person::lookup_person($user_name,$source);\n+            } else {\n+                $logger->debug(\"person $user_name already exists\");\n             }\n-            if (defined $value) {\n-                $value = pf::config::dynamic_unreg_date($value);\n-                my %info = (\n-                    'unregdate' => $value,\n-                    'category' => $role,\n-                    'autoreg' => 'yes',\n-                    'pid' => $user_name,\n-                );\n-                if (defined $role) {\n-                    %info = (%info, (category => $role));\n-                }\n-                # create a person entry for pid if it doesn't exist\n-                if ( !pf::person::person_exist($user_name) ) {\n-                    $logger->info(\"creating person $user_name because it doesn't exist\");\n-                    pf::person::person_add($user_name);\n-                    pf::lookup::person::lookup_person($user_name,$source);\n-                } else {\n-                    $logger->debug(\"person $user_name already exists\");\n-                }\n-                pf::person::person_modify($user_name,\n-                    'source'  => $source,\n-                    'portal'  => $profile->getName,\n-                );\n-                node_modify($mac,%info);\n+            pf::person::person_modify($user_name,\n+                'source'  => $source,\n+                'portal'  => $profile->getName,\n+            );\n+            my %info = (\n+                'autoreg' => 'no',","path":"lib/pf/vlan.pm","position":185,"original_position":185,"commit_id":"17f36fa4df883b801dee722a2f2b3fd81f57aff1","original_commit_id":"17f36fa4df883b801dee722a2f2b3fd81f57aff1","user":{"login":"fdurand","id":1553962,"avatar_url":"https://avatars.githubusercontent.com/u/1553962?v=3","gravatar_id":"","url":"https://api.github.com/users/fdurand","html_url":"https://github.com/fdurand","followers_url":"https://api.github.com/users/fdurand/followers","following_url":"https://api.github.com/users/fdurand/following{/other_user}","gists_url":"https://api.github.com/users/fdurand/gists{/gist_id}","starred_url":"https://api.github.com/users/fdurand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdurand/subscriptions","organizations_url":"https://api.github.com/users/fdurand/orgs","repos_url":"https://api.github.com/users/fdurand/repos","events_url":"https://api.github.com/users/fdurand/events{/privacy}","received_events_url":"https://api.github.com/users/fdurand/received_events","type":"User","site_admin":false},"body":"(isenabled($node_info->{'autoreg'}) && $autoreg) mean that we are not in autoreg workflow so i have to set autoreg to no","created_at":"2015-02-19T14:23:00Z","updated_at":"2015-02-19T14:23:00Z","html_url":"https://github.com/inverse-inc/packetfence/pull/330#discussion_r24990349","pull_request_url":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330","_links":{"self":{"href":"https://api.github.com/repos/inverse-inc/packetfence/pulls/comments/24990349"},"html":{"href":"https://github.com/inverse-inc/packetfence/pull/330#discussion_r24990349"},"pull_request":{"href":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330"}}},"pull_request":{"url":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330","id":28650696,"html_url":"https://github.com/inverse-inc/packetfence/pull/330","diff_url":"https://github.com/inverse-inc/packetfence/pull/330.diff","patch_url":"https://github.com/inverse-inc/packetfence/pull/330.patch","issue_url":"https://api.github.com/repos/inverse-inc/packetfence/issues/330","number":330,"state":"open","locked":false,"title":"Reworked vlan.pm for autoregistration and added a new configuration parameter on the portal to recompute or no the role in case of 802.1x connection","user":{"login":"fdurand","id":1553962,"avatar_url":"https://avatars.githubusercontent.com/u/1553962?v=3","gravatar_id":"","url":"https://api.github.com/users/fdurand","html_url":"https://github.com/fdurand","followers_url":"https://api.github.com/users/fdurand/followers","following_url":"https://api.github.com/users/fdurand/following{/other_user}","gists_url":"https://api.github.com/users/fdurand/gists{/gist_id}","starred_url":"https://api.github.com/users/fdurand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdurand/subscriptions","organizations_url":"https://api.github.com/users/fdurand/orgs","repos_url":"https://api.github.com/users/fdurand/repos","events_url":"https://api.github.com/users/fdurand/events{/privacy}","received_events_url":"https://api.github.com/users/fdurand/received_events","type":"User","site_admin":false},"body":"Description\r\n-----------\r\nMoved code from getNormalVlan to getNodeInfoForAutoreg.\r\nIf we configure autoregistration then the role and access duration will be compute in getNodeInfoForAutoreg instead of in getNormalVlan.  With that we will be able to create vlan filter rules in getNormalVlan based on the role of the device. \r\nAdded a new parameter in the portal profile to compute or not the role based on the 802.1x userid (registration has been made on the portal)\r\nAdded a test to be sure that even if the node has been autoregistered on a 802.1x connection it pass in autoreg section (if no then we compute the role on the portal profile) \r\n\r\nImpacts\r\n-------\r\nSimplify getNormalVlan \r\n\r\nNEWS file entries\r\n-------\r\nRefactored autoregistration workflow in getNormalVlan and getNodeInfoForAutoreg\r\n\r\nDelete branch after merge\r\n-------------------------\r\nYes","created_at":"2015-02-04T16:11:53Z","updated_at":"2015-02-19T14:23:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"034affe69f9da4ca2e8271583741a071b302cde3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330/commits","review_comments_url":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330/comments","review_comment_url":"https://api.github.com/repos/inverse-inc/packetfence/pulls/comments/{number}","comments_url":"https://api.github.com/repos/inverse-inc/packetfence/issues/330/comments","statuses_url":"https://api.github.com/repos/inverse-inc/packetfence/statuses/17f36fa4df883b801dee722a2f2b3fd81f57aff1","head":{"label":"feature/rework_getInfoForAutoReg","ref":"feature/rework_getInfoForAutoReg","sha":"17f36fa4df883b801dee722a2f2b3fd81f57aff1","user":{"login":"inverse-inc","id":1203154,"avatar_url":"https://avatars.githubusercontent.com/u/1203154?v=3","gravatar_id":"","url":"https://api.github.com/users/inverse-inc","html_url":"https://github.com/inverse-inc","followers_url":"https://api.github.com/users/inverse-inc/followers","following_url":"https://api.github.com/users/inverse-inc/following{/other_user}","gists_url":"https://api.github.com/users/inverse-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/inverse-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inverse-inc/subscriptions","organizations_url":"https://api.github.com/users/inverse-inc/orgs","repos_url":"https://api.github.com/users/inverse-inc/repos","events_url":"https://api.github.com/users/inverse-inc/events{/privacy}","received_events_url":"https://api.github.com/users/inverse-inc/received_events","type":"Organization","site_admin":false},"repo":{"id":3595658,"name":"packetfence","full_name":"inverse-inc/packetfence","owner":{"login":"inverse-inc","id":1203154,"avatar_url":"https://avatars.githubusercontent.com/u/1203154?v=3","gravatar_id":"","url":"https://api.github.com/users/inverse-inc","html_url":"https://github.com/inverse-inc","followers_url":"https://api.github.com/users/inverse-inc/followers","following_url":"https://api.github.com/users/inverse-inc/following{/other_user}","gists_url":"https://api.github.com/users/inverse-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/inverse-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inverse-inc/subscriptions","organizations_url":"https://api.github.com/users/inverse-inc/orgs","repos_url":"https://api.github.com/users/inverse-inc/repos","events_url":"https://api.github.com/users/inverse-inc/events{/privacy}","received_events_url":"https://api.github.com/users/inverse-inc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inverse-inc/packetfence","description":"PacketFence is a fully supported, trusted, Free and Open Source network access control (NAC) solution. Boasting an impressive feature set including a captive-portal for registration and remediation, centralized wired and wireless management, powerful guest management options, 802.1X support, layer-2 isolation of problematic devices; PacketFence can be used to effectively secure networks small to very large heterogeneous networks.","fork":false,"url":"https://api.github.com/repos/inverse-inc/packetfence","forks_url":"https://api.github.com/repos/inverse-inc/packetfence/forks","keys_url":"https://api.github.com/repos/inverse-inc/packetfence/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inverse-inc/packetfence/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inverse-inc/packetfence/teams","hooks_url":"https://api.github.com/repos/inverse-inc/packetfence/hooks","issue_events_url":"https://api.github.com/repos/inverse-inc/packetfence/issues/events{/number}","events_url":"https://api.github.com/repos/inverse-inc/packetfence/events","assignees_url":"https://api.github.com/repos/inverse-inc/packetfence/assignees{/user}","branches_url":"https://api.github.com/repos/inverse-inc/packetfence/branches{/branch}","tags_url":"https://api.github.com/repos/inverse-inc/packetfence/tags","blobs_url":"https://api.github.com/repos/inverse-inc/packetfence/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inverse-inc/packetfence/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inverse-inc/packetfence/git/refs{/sha}","trees_url":"https://api.github.com/repos/inverse-inc/packetfence/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inverse-inc/packetfence/statuses/{sha}","languages_url":"https://api.github.com/repos/inverse-inc/packetfence/languages","stargazers_url":"https://api.github.com/repos/inverse-inc/packetfence/stargazers","contributors_url":"https://api.github.com/repos/inverse-inc/packetfence/contributors","subscribers_url":"https://api.github.com/repos/inverse-inc/packetfence/subscribers","subscription_url":"https://api.github.com/repos/inverse-inc/packetfence/subscription","commits_url":"https://api.github.com/repos/inverse-inc/packetfence/commits{/sha}","git_commits_url":"https://api.github.com/repos/inverse-inc/packetfence/git/commits{/sha}","comments_url":"https://api.github.com/repos/inverse-inc/packetfence/comments{/number}","issue_comment_url":"https://api.github.com/repos/inverse-inc/packetfence/issues/comments/{number}","contents_url":"https://api.github.com/repos/inverse-inc/packetfence/contents/{+path}","compare_url":"https://api.github.com/repos/inverse-inc/packetfence/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inverse-inc/packetfence/merges","archive_url":"https://api.github.com/repos/inverse-inc/packetfence/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inverse-inc/packetfence/downloads","issues_url":"https://api.github.com/repos/inverse-inc/packetfence/issues{/number}","pulls_url":"https://api.github.com/repos/inverse-inc/packetfence/pulls{/number}","milestones_url":"https://api.github.com/repos/inverse-inc/packetfence/milestones{/number}","notifications_url":"https://api.github.com/repos/inverse-inc/packetfence/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inverse-inc/packetfence/labels{/name}","releases_url":"https://api.github.com/repos/inverse-inc/packetfence/releases{/id}","created_at":"2012-03-01T20:21:13Z","updated_at":"2015-02-19T13:59:04Z","pushed_at":"2015-02-19T13:58:59Z","git_url":"git://github.com/inverse-inc/packetfence.git","ssh_url":"git@github.com:inverse-inc/packetfence.git","clone_url":"https://github.com/inverse-inc/packetfence.git","svn_url":"https://github.com/inverse-inc/packetfence","homepage":"http://www.packetfence.org","size":107312,"stargazers_count":103,"watchers_count":103,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":57,"mirror_url":null,"open_issues_count":50,"forks":57,"open_issues":50,"watchers":103,"default_branch":"devel"}},"base":{"label":"devel","ref":"devel","sha":"ee9b8219eb564c5626a9ac6f39e772a3c89b3444","user":{"login":"inverse-inc","id":1203154,"avatar_url":"https://avatars.githubusercontent.com/u/1203154?v=3","gravatar_id":"","url":"https://api.github.com/users/inverse-inc","html_url":"https://github.com/inverse-inc","followers_url":"https://api.github.com/users/inverse-inc/followers","following_url":"https://api.github.com/users/inverse-inc/following{/other_user}","gists_url":"https://api.github.com/users/inverse-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/inverse-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inverse-inc/subscriptions","organizations_url":"https://api.github.com/users/inverse-inc/orgs","repos_url":"https://api.github.com/users/inverse-inc/repos","events_url":"https://api.github.com/users/inverse-inc/events{/privacy}","received_events_url":"https://api.github.com/users/inverse-inc/received_events","type":"Organization","site_admin":false},"repo":{"id":3595658,"name":"packetfence","full_name":"inverse-inc/packetfence","owner":{"login":"inverse-inc","id":1203154,"avatar_url":"https://avatars.githubusercontent.com/u/1203154?v=3","gravatar_id":"","url":"https://api.github.com/users/inverse-inc","html_url":"https://github.com/inverse-inc","followers_url":"https://api.github.com/users/inverse-inc/followers","following_url":"https://api.github.com/users/inverse-inc/following{/other_user}","gists_url":"https://api.github.com/users/inverse-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/inverse-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inverse-inc/subscriptions","organizations_url":"https://api.github.com/users/inverse-inc/orgs","repos_url":"https://api.github.com/users/inverse-inc/repos","events_url":"https://api.github.com/users/inverse-inc/events{/privacy}","received_events_url":"https://api.github.com/users/inverse-inc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inverse-inc/packetfence","description":"PacketFence is a fully supported, trusted, Free and Open Source network access control (NAC) solution. Boasting an impressive feature set including a captive-portal for registration and remediation, centralized wired and wireless management, powerful guest management options, 802.1X support, layer-2 isolation of problematic devices; PacketFence can be used to effectively secure networks small to very large heterogeneous networks.","fork":false,"url":"https://api.github.com/repos/inverse-inc/packetfence","forks_url":"https://api.github.com/repos/inverse-inc/packetfence/forks","keys_url":"https://api.github.com/repos/inverse-inc/packetfence/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inverse-inc/packetfence/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inverse-inc/packetfence/teams","hooks_url":"https://api.github.com/repos/inverse-inc/packetfence/hooks","issue_events_url":"https://api.github.com/repos/inverse-inc/packetfence/issues/events{/number}","events_url":"https://api.github.com/repos/inverse-inc/packetfence/events","assignees_url":"https://api.github.com/repos/inverse-inc/packetfence/assignees{/user}","branches_url":"https://api.github.com/repos/inverse-inc/packetfence/branches{/branch}","tags_url":"https://api.github.com/repos/inverse-inc/packetfence/tags","blobs_url":"https://api.github.com/repos/inverse-inc/packetfence/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inverse-inc/packetfence/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inverse-inc/packetfence/git/refs{/sha}","trees_url":"https://api.github.com/repos/inverse-inc/packetfence/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inverse-inc/packetfence/statuses/{sha}","languages_url":"https://api.github.com/repos/inverse-inc/packetfence/languages","stargazers_url":"https://api.github.com/repos/inverse-inc/packetfence/stargazers","contributors_url":"https://api.github.com/repos/inverse-inc/packetfence/contributors","subscribers_url":"https://api.github.com/repos/inverse-inc/packetfence/subscribers","subscription_url":"https://api.github.com/repos/inverse-inc/packetfence/subscription","commits_url":"https://api.github.com/repos/inverse-inc/packetfence/commits{/sha}","git_commits_url":"https://api.github.com/repos/inverse-inc/packetfence/git/commits{/sha}","comments_url":"https://api.github.com/repos/inverse-inc/packetfence/comments{/number}","issue_comment_url":"https://api.github.com/repos/inverse-inc/packetfence/issues/comments/{number}","contents_url":"https://api.github.com/repos/inverse-inc/packetfence/contents/{+path}","compare_url":"https://api.github.com/repos/inverse-inc/packetfence/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inverse-inc/packetfence/merges","archive_url":"https://api.github.com/repos/inverse-inc/packetfence/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inverse-inc/packetfence/downloads","issues_url":"https://api.github.com/repos/inverse-inc/packetfence/issues{/number}","pulls_url":"https://api.github.com/repos/inverse-inc/packetfence/pulls{/number}","milestones_url":"https://api.github.com/repos/inverse-inc/packetfence/milestones{/number}","notifications_url":"https://api.github.com/repos/inverse-inc/packetfence/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inverse-inc/packetfence/labels{/name}","releases_url":"https://api.github.com/repos/inverse-inc/packetfence/releases{/id}","created_at":"2012-03-01T20:21:13Z","updated_at":"2015-02-19T13:59:04Z","pushed_at":"2015-02-19T13:58:59Z","git_url":"git://github.com/inverse-inc/packetfence.git","ssh_url":"git@github.com:inverse-inc/packetfence.git","clone_url":"https://github.com/inverse-inc/packetfence.git","svn_url":"https://github.com/inverse-inc/packetfence","homepage":"http://www.packetfence.org","size":107312,"stargazers_count":103,"watchers_count":103,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":57,"mirror_url":null,"open_issues_count":50,"forks":57,"open_issues":50,"watchers":103,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330"},"html":{"href":"https://github.com/inverse-inc/packetfence/pull/330"},"issue":{"href":"https://api.github.com/repos/inverse-inc/packetfence/issues/330"},"comments":{"href":"https://api.github.com/repos/inverse-inc/packetfence/issues/330/comments"},"review_comments":{"href":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330/comments"},"review_comment":{"href":"https://api.github.com/repos/inverse-inc/packetfence/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/inverse-inc/packetfence/pulls/330/commits"},"statuses":{"href":"https://api.github.com/repos/inverse-inc/packetfence/statuses/17f36fa4df883b801dee722a2f2b3fd81f57aff1"}}}}