{"action":"created","comment":{"url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments/190511730","pull_request_review_id":122901067,"id":190511730,"diff_hunk":"@@ -252,6 +259,39 @@ protected HttpMessage prepareRequestMessage(UsernamePasswordAuthenticationCreden\n \t\t\treturn requestMessage;\n \t\t}\n \n+\t\tprivate void replaceAntiCsrfTokenAndCookieValueIfRequired(HttpMessage requestMessage, User user) throws NullPointerException, IOException {\n+\t\t\tif(extAntiCsrf == null) {\n+\t\t\t\textAntiCsrf = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAntiCSRF.class);\n+\t\t\t}\n+\t\t\tList<AntiCsrfToken> antiCsrfTokensOfFirstLoginMsg = null;\n+\t\t\tif(extAntiCsrf != null) {\n+\t\t\t\tantiCsrfTokensOfFirstLoginMsg = extAntiCsrf.getTokens(this.loginRequestBody, this.loginRequestURL);\n+\t\t\t}\n+\t\t\tAntiCsrfToken antiCsrfTokenOfFirstLoginMsg = null;\n+\t\t\tif(antiCsrfTokensOfFirstLoginMsg != null && antiCsrfTokensOfFirstLoginMsg.size() > 0) {\n+\t\t\t\tantiCsrfTokenOfFirstLoginMsg = antiCsrfTokensOfFirstLoginMsg.get(0);\n+\t\t\t}\n+\t\t\t\n+\t\t\tif (antiCsrfTokenOfFirstLoginMsg != null) {\n+\t\t\t\tthis.requireAntiCsrfTokenWhenLogin = true;\n+\t\t\t\tHttpMessage loginMsgToRegenerateAntiCsrfToken = antiCsrfTokenOfFirstLoginMsg.getMsg().cloneAll();\n+//\t\t\t\tloginMsgToRegenerateAntiCsrfToken.setRequestingUser(user);\n+\t\t\t\t\n+\t\t\t\tgetHttpSender().sendAndReceive(loginMsgToRegenerateAntiCsrfToken);\n+","path":"src/org/zaproxy/zap/authentication/PostBasedAuthenticationMethodType.java","position":58,"original_position":58,"commit_id":"3d534ed5e859fe5686bb388cbeb5a556728ffa38","original_commit_id":"3d534ed5e859fe5686bb388cbeb5a556728ffa38","user":{"login":"thc202","id":4639210,"avatar_url":"https://avatars0.githubusercontent.com/u/4639210?v=4","gravatar_id":"","url":"https://api.github.com/users/thc202","html_url":"https://github.com/thc202","followers_url":"https://api.github.com/users/thc202/followers","following_url":"https://api.github.com/users/thc202/following{/other_user}","gists_url":"https://api.github.com/users/thc202/gists{/gist_id}","starred_url":"https://api.github.com/users/thc202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thc202/subscriptions","organizations_url":"https://api.github.com/users/thc202/orgs","repos_url":"https://api.github.com/users/thc202/repos","events_url":"https://api.github.com/users/thc202/events{/privacy}","received_events_url":"https://api.github.com/users/thc202/received_events","type":"User","site_admin":false},"body":"Worth calling here `AuthenticationHelper.addAuthMessageToHistory(loginMsgToRegenerateAntiCsrfToken);` to show the message to the user.","created_at":"2018-05-24T08:58:37Z","updated_at":"2018-05-24T08:58:37Z","html_url":"https://github.com/zaproxy/zaproxy/pull/4682#discussion_r190511730","pull_request_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments/190511730"},"html":{"href":"https://github.com/zaproxy/zaproxy/pull/4682#discussion_r190511730"},"pull_request":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682"}}},"pull_request":{"url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682","id":189361405,"html_url":"https://github.com/zaproxy/zaproxy/pull/4682","diff_url":"https://github.com/zaproxy/zaproxy/pull/4682.diff","patch_url":"https://github.com/zaproxy/zaproxy/pull/4682.patch","issue_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/4682","number":4682,"state":"open","locked":false,"title":"support reauthentication in the presence of an anti-CSRF token for post based authentication method type.","user":{"login":"KajanM","id":17596394,"avatar_url":"https://avatars1.githubusercontent.com/u/17596394?v=4","gravatar_id":"","url":"https://api.github.com/users/KajanM","html_url":"https://github.com/KajanM","followers_url":"https://api.github.com/users/KajanM/followers","following_url":"https://api.github.com/users/KajanM/following{/other_user}","gists_url":"https://api.github.com/users/KajanM/gists{/gist_id}","starred_url":"https://api.github.com/users/KajanM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KajanM/subscriptions","organizations_url":"https://api.github.com/users/KajanM/orgs","repos_url":"https://api.github.com/users/KajanM/repos","events_url":"https://api.github.com/users/KajanM/events{/privacy}","received_events_url":"https://api.github.com/users/KajanM/received_events","type":"User","site_admin":false},"body":"#2182 \r\nif authentication requires an anti-CSRF token then this change\r\n1. makes a `GET` request to the login page.\r\n1. gets the fresh token value from the response.\r\n1. prepares `POST` request by replacing the old token value in the `RequestBody` of the first `POST` request to login page with the new token value.\r\n1. gets the cookies from the response of `GET` request to login page just made to regenerate token\r\n1. sets the cookies to the `POST` message that will be sent for authentication purpose\r\n1. sends and receives the prepared request message","created_at":"2018-05-21T12:09:32Z","updated_at":"2018-05-24T08:58:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ad2bc52e616cc9915b67cd670f0b01d3d0acbbe2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":220536002,"url":"https://api.github.com/repos/zaproxy/zaproxy/labels/Type-Task","name":"Type-Task","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682/commits","review_comments_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682/comments","review_comment_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/4682/comments","statuses_url":"https://api.github.com/repos/zaproxy/zaproxy/statuses/3d534ed5e859fe5686bb388cbeb5a556728ffa38","head":{"label":"KajanM:dynamic-token-authentication","ref":"dynamic-token-authentication","sha":"3d534ed5e859fe5686bb388cbeb5a556728ffa38","user":{"login":"KajanM","id":17596394,"avatar_url":"https://avatars1.githubusercontent.com/u/17596394?v=4","gravatar_id":"","url":"https://api.github.com/users/KajanM","html_url":"https://github.com/KajanM","followers_url":"https://api.github.com/users/KajanM/followers","following_url":"https://api.github.com/users/KajanM/following{/other_user}","gists_url":"https://api.github.com/users/KajanM/gists{/gist_id}","starred_url":"https://api.github.com/users/KajanM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KajanM/subscriptions","organizations_url":"https://api.github.com/users/KajanM/orgs","repos_url":"https://api.github.com/users/KajanM/repos","events_url":"https://api.github.com/users/KajanM/events{/privacy}","received_events_url":"https://api.github.com/users/KajanM/received_events","type":"User","site_admin":false},"repo":{"id":122687100,"name":"zaproxy","full_name":"KajanM/zaproxy","owner":{"login":"KajanM","id":17596394,"avatar_url":"https://avatars1.githubusercontent.com/u/17596394?v=4","gravatar_id":"","url":"https://api.github.com/users/KajanM","html_url":"https://github.com/KajanM","followers_url":"https://api.github.com/users/KajanM/followers","following_url":"https://api.github.com/users/KajanM/following{/other_user}","gists_url":"https://api.github.com/users/KajanM/gists{/gist_id}","starred_url":"https://api.github.com/users/KajanM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KajanM/subscriptions","organizations_url":"https://api.github.com/users/KajanM/orgs","repos_url":"https://api.github.com/users/KajanM/repos","events_url":"https://api.github.com/users/KajanM/events{/privacy}","received_events_url":"https://api.github.com/users/KajanM/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KajanM/zaproxy","description":"The OWASP ZAP core project","fork":true,"url":"https://api.github.com/repos/KajanM/zaproxy","forks_url":"https://api.github.com/repos/KajanM/zaproxy/forks","keys_url":"https://api.github.com/repos/KajanM/zaproxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KajanM/zaproxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KajanM/zaproxy/teams","hooks_url":"https://api.github.com/repos/KajanM/zaproxy/hooks","issue_events_url":"https://api.github.com/repos/KajanM/zaproxy/issues/events{/number}","events_url":"https://api.github.com/repos/KajanM/zaproxy/events","assignees_url":"https://api.github.com/repos/KajanM/zaproxy/assignees{/user}","branches_url":"https://api.github.com/repos/KajanM/zaproxy/branches{/branch}","tags_url":"https://api.github.com/repos/KajanM/zaproxy/tags","blobs_url":"https://api.github.com/repos/KajanM/zaproxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KajanM/zaproxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KajanM/zaproxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/KajanM/zaproxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KajanM/zaproxy/statuses/{sha}","languages_url":"https://api.github.com/repos/KajanM/zaproxy/languages","stargazers_url":"https://api.github.com/repos/KajanM/zaproxy/stargazers","contributors_url":"https://api.github.com/repos/KajanM/zaproxy/contributors","subscribers_url":"https://api.github.com/repos/KajanM/zaproxy/subscribers","subscription_url":"https://api.github.com/repos/KajanM/zaproxy/subscription","commits_url":"https://api.github.com/repos/KajanM/zaproxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/KajanM/zaproxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/KajanM/zaproxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/KajanM/zaproxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/KajanM/zaproxy/contents/{+path}","compare_url":"https://api.github.com/repos/KajanM/zaproxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KajanM/zaproxy/merges","archive_url":"https://api.github.com/repos/KajanM/zaproxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KajanM/zaproxy/downloads","issues_url":"https://api.github.com/repos/KajanM/zaproxy/issues{/number}","pulls_url":"https://api.github.com/repos/KajanM/zaproxy/pulls{/number}","milestones_url":"https://api.github.com/repos/KajanM/zaproxy/milestones{/number}","notifications_url":"https://api.github.com/repos/KajanM/zaproxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KajanM/zaproxy/labels{/name}","releases_url":"https://api.github.com/repos/KajanM/zaproxy/releases{/id}","deployments_url":"https://api.github.com/repos/KajanM/zaproxy/deployments","created_at":"2018-02-24T00:30:38Z","updated_at":"2018-05-12T09:24:16Z","pushed_at":"2018-05-22T13:03:40Z","git_url":"git://github.com/KajanM/zaproxy.git","ssh_url":"git@github.com:KajanM/zaproxy.git","clone_url":"https://github.com/KajanM/zaproxy.git","svn_url":"https://github.com/KajanM/zaproxy","homepage":null,"size":175875,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"zaproxy:develop","ref":"develop","sha":"a6195c9d0e6e413e840f066fda56c800d1ddf71f","user":{"login":"zaproxy","id":6716868,"avatar_url":"https://avatars2.githubusercontent.com/u/6716868?v=4","gravatar_id":"","url":"https://api.github.com/users/zaproxy","html_url":"https://github.com/zaproxy","followers_url":"https://api.github.com/users/zaproxy/followers","following_url":"https://api.github.com/users/zaproxy/following{/other_user}","gists_url":"https://api.github.com/users/zaproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/zaproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaproxy/subscriptions","organizations_url":"https://api.github.com/users/zaproxy/orgs","repos_url":"https://api.github.com/users/zaproxy/repos","events_url":"https://api.github.com/users/zaproxy/events{/privacy}","received_events_url":"https://api.github.com/users/zaproxy/received_events","type":"Organization","site_admin":false},"repo":{"id":36817565,"name":"zaproxy","full_name":"zaproxy/zaproxy","owner":{"login":"zaproxy","id":6716868,"avatar_url":"https://avatars2.githubusercontent.com/u/6716868?v=4","gravatar_id":"","url":"https://api.github.com/users/zaproxy","html_url":"https://github.com/zaproxy","followers_url":"https://api.github.com/users/zaproxy/followers","following_url":"https://api.github.com/users/zaproxy/following{/other_user}","gists_url":"https://api.github.com/users/zaproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/zaproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaproxy/subscriptions","organizations_url":"https://api.github.com/users/zaproxy/orgs","repos_url":"https://api.github.com/users/zaproxy/repos","events_url":"https://api.github.com/users/zaproxy/events{/privacy}","received_events_url":"https://api.github.com/users/zaproxy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zaproxy/zaproxy","description":"The OWASP ZAP core project","fork":false,"url":"https://api.github.com/repos/zaproxy/zaproxy","forks_url":"https://api.github.com/repos/zaproxy/zaproxy/forks","keys_url":"https://api.github.com/repos/zaproxy/zaproxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zaproxy/zaproxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zaproxy/zaproxy/teams","hooks_url":"https://api.github.com/repos/zaproxy/zaproxy/hooks","issue_events_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/events{/number}","events_url":"https://api.github.com/repos/zaproxy/zaproxy/events","assignees_url":"https://api.github.com/repos/zaproxy/zaproxy/assignees{/user}","branches_url":"https://api.github.com/repos/zaproxy/zaproxy/branches{/branch}","tags_url":"https://api.github.com/repos/zaproxy/zaproxy/tags","blobs_url":"https://api.github.com/repos/zaproxy/zaproxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zaproxy/zaproxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zaproxy/zaproxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/zaproxy/zaproxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zaproxy/zaproxy/statuses/{sha}","languages_url":"https://api.github.com/repos/zaproxy/zaproxy/languages","stargazers_url":"https://api.github.com/repos/zaproxy/zaproxy/stargazers","contributors_url":"https://api.github.com/repos/zaproxy/zaproxy/contributors","subscribers_url":"https://api.github.com/repos/zaproxy/zaproxy/subscribers","subscription_url":"https://api.github.com/repos/zaproxy/zaproxy/subscription","commits_url":"https://api.github.com/repos/zaproxy/zaproxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/zaproxy/zaproxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/zaproxy/zaproxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/zaproxy/zaproxy/contents/{+path}","compare_url":"https://api.github.com/repos/zaproxy/zaproxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zaproxy/zaproxy/merges","archive_url":"https://api.github.com/repos/zaproxy/zaproxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zaproxy/zaproxy/downloads","issues_url":"https://api.github.com/repos/zaproxy/zaproxy/issues{/number}","pulls_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls{/number}","milestones_url":"https://api.github.com/repos/zaproxy/zaproxy/milestones{/number}","notifications_url":"https://api.github.com/repos/zaproxy/zaproxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zaproxy/zaproxy/labels{/name}","releases_url":"https://api.github.com/repos/zaproxy/zaproxy/releases{/id}","deployments_url":"https://api.github.com/repos/zaproxy/zaproxy/deployments","created_at":"2015-06-03T16:55:01Z","updated_at":"2018-05-24T05:39:23Z","pushed_at":"2018-05-23T13:49:16Z","git_url":"git://github.com/zaproxy/zaproxy.git","ssh_url":"git@github.com:zaproxy/zaproxy.git","clone_url":"https://github.com/zaproxy/zaproxy.git","svn_url":"https://github.com/zaproxy/zaproxy","homepage":null,"size":175951,"stargazers_count":3954,"watchers_count":3954,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":766,"mirror_url":null,"archived":false,"open_issues_count":605,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":766,"open_issues":605,"watchers":3954,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682"},"html":{"href":"https://github.com/zaproxy/zaproxy/pull/4682"},"issue":{"href":"https://api.github.com/repos/zaproxy/zaproxy/issues/4682"},"comments":{"href":"https://api.github.com/repos/zaproxy/zaproxy/issues/4682/comments"},"review_comments":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682/comments"},"review_comment":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4682/commits"},"statuses":{"href":"https://api.github.com/repos/zaproxy/zaproxy/statuses/3d534ed5e859fe5686bb388cbeb5a556728ffa38"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"thc202"}}