{"action":"created","comment":{"url":"https://api.github.com/repos/pycontribs/jira/pulls/comments/211722582","pull_request_review_id":148204609,"id":211722582,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTcyMjU4Mg==","diff_hunk":"@@ -2631,9 +2631,28 @@ def delete_user(self, username):\n     def deactivate_user(self, username):\n         \"\"\"Disable/deactivate the user.\"\"\"\n         if self.deploymentType == 'Cloud':\n-            url = self._options['server'] + '/admin/rest/um/1/user/deactivate?username=' + username\n-            self._options['headers']['Content-Type'] = 'application/json'\n-            userInfo = {}\n+            # Disabling users now needs cookie auth in the Cloud - see https://jira.atlassian.com/browse/ID-6230\n+            if 'authCookie' not in vars(self):\n+                user = self.session()\n+                if user.raw is None:\n+                    auth_method = (\n+                        oauth or basic_auth or jwt or kerberos or \"anonymous\"\n+                    )\n+                    raise JIRAError(\"Can not log in with %s\" % str(auth_method))\n+                self.authCookie = '%s=%s' % (user.raw['session']['name'], user.raw['session']['value'])\n+            url = self._options['server'] + '/admin/rest/um/1/user/deactivate?username=%s' % (username)\n+            # We can't use our existing session here - this endpoint is fragile and objects to extra headers\n+            try:\n+                r = requests.post(url, headers={'Cookie': self.authCookie, 'Content-Type': 'application/json'}, data={})\n+                if r.status_code == 200:\n+                    return True\n+                else:\n+                    logging.warning(\n+                        'Got response from deactivating %s: %s' % (username, r.status_code))\n+                    return r.status_code\n+            except urllib2.HTTPError as e:\n+                logging.error(\n+                        \"Error Deactivating %s: %s\" % (username, e))","path":"jira/client.py","position":28,"original_position":28,"commit_id":"8f928d2a9531870d70daecf67c10700b557cf59f","original_commit_id":"8f928d2a9531870d70daecf67c10700b557cf59f","user":{"login":"ssbarnea","id":102495,"node_id":"MDQ6VXNlcjEwMjQ5NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/102495?v=4","gravatar_id":"","url":"https://api.github.com/users/ssbarnea","html_url":"https://github.com/ssbarnea","followers_url":"https://api.github.com/users/ssbarnea/followers","following_url":"https://api.github.com/users/ssbarnea/following{/other_user}","gists_url":"https://api.github.com/users/ssbarnea/gists{/gist_id}","starred_url":"https://api.github.com/users/ssbarnea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssbarnea/subscriptions","organizations_url":"https://api.github.com/users/ssbarnea/orgs","repos_url":"https://api.github.com/users/ssbarnea/repos","events_url":"https://api.github.com/users/ssbarnea/events{/privacy}","received_events_url":"https://api.github.com/users/ssbarnea/received_events","type":"User","site_admin":false},"body":"I am not sure we want to catch exceptions and hide them. I think that we should raise a JiraError instead, or at least return False. Otherwise consumers of this function would not be able to know if call succeeded or not.\r\n\r\nSame applies for the code below.\r\n\r\nAlso I wonder if we can avoid duplicating so much code between cloud mode and self-hosted one.","created_at":"2018-08-21T19:01:53Z","updated_at":"2018-08-21T19:02:01Z","html_url":"https://github.com/pycontribs/jira/pull/616#discussion_r211722582","pull_request_url":"https://api.github.com/repos/pycontribs/jira/pulls/616","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pycontribs/jira/pulls/comments/211722582"},"html":{"href":"https://github.com/pycontribs/jira/pull/616#discussion_r211722582"},"pull_request":{"href":"https://api.github.com/repos/pycontribs/jira/pulls/616"}}},"pull_request":{"url":"https://api.github.com/repos/pycontribs/jira/pulls/616","id":198791095,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NzkxMDk1","html_url":"https://github.com/pycontribs/jira/pull/616","diff_url":"https://github.com/pycontribs/jira/pull/616.diff","patch_url":"https://github.com/pycontribs/jira/pull/616.patch","issue_url":"https://api.github.com/repos/pycontribs/jira/issues/616","number":616,"state":"open","locked":false,"title":"Zoeimogen feature/deactivate user cookie","user":{"login":"hdost","id":643846,"node_id":"MDQ6VXNlcjY0Mzg0Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/643846?v=4","gravatar_id":"","url":"https://api.github.com/users/hdost","html_url":"https://github.com/hdost","followers_url":"https://api.github.com/users/hdost/followers","following_url":"https://api.github.com/users/hdost/following{/other_user}","gists_url":"https://api.github.com/users/hdost/gists{/gist_id}","starred_url":"https://api.github.com/users/hdost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hdost/subscriptions","organizations_url":"https://api.github.com/users/hdost/orgs","repos_url":"https://api.github.com/users/hdost/repos","events_url":"https://api.github.com/users/hdost/events{/privacy}","received_events_url":"https://api.github.com/users/hdost/received_events","type":"User","site_admin":false},"body":"Supersedes: #434 from @zoeimogen","created_at":"2018-07-02T21:13:58Z","updated_at":"2018-08-21T19:02:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efea1f8361c61d210f183f0c12f8b0666903eba2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pycontribs/jira/pulls/616/commits","review_comments_url":"https://api.github.com/repos/pycontribs/jira/pulls/616/comments","review_comment_url":"https://api.github.com/repos/pycontribs/jira/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pycontribs/jira/issues/616/comments","statuses_url":"https://api.github.com/repos/pycontribs/jira/statuses/8f928d2a9531870d70daecf67c10700b557cf59f","head":{"label":"criteo-forks:zoeimogen-feature/deactivate-user-cookie","ref":"zoeimogen-feature/deactivate-user-cookie","sha":"8f928d2a9531870d70daecf67c10700b557cf59f","user":{"login":"criteo-forks","id":9960514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5NjA1MTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/9960514?v=4","gravatar_id":"","url":"https://api.github.com/users/criteo-forks","html_url":"https://github.com/criteo-forks","followers_url":"https://api.github.com/users/criteo-forks/followers","following_url":"https://api.github.com/users/criteo-forks/following{/other_user}","gists_url":"https://api.github.com/users/criteo-forks/gists{/gist_id}","starred_url":"https://api.github.com/users/criteo-forks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/criteo-forks/subscriptions","organizations_url":"https://api.github.com/users/criteo-forks/orgs","repos_url":"https://api.github.com/users/criteo-forks/repos","events_url":"https://api.github.com/users/criteo-forks/events{/privacy}","received_events_url":"https://api.github.com/users/criteo-forks/received_events","type":"Organization","site_admin":false},"repo":{"id":110129787,"node_id":"MDEwOlJlcG9zaXRvcnkxMTAxMjk3ODc=","name":"jira-1","full_name":"criteo-forks/jira-1","owner":{"login":"criteo-forks","id":9960514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5NjA1MTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/9960514?v=4","gravatar_id":"","url":"https://api.github.com/users/criteo-forks","html_url":"https://github.com/criteo-forks","followers_url":"https://api.github.com/users/criteo-forks/followers","following_url":"https://api.github.com/users/criteo-forks/following{/other_user}","gists_url":"https://api.github.com/users/criteo-forks/gists{/gist_id}","starred_url":"https://api.github.com/users/criteo-forks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/criteo-forks/subscriptions","organizations_url":"https://api.github.com/users/criteo-forks/orgs","repos_url":"https://api.github.com/users/criteo-forks/repos","events_url":"https://api.github.com/users/criteo-forks/events{/privacy}","received_events_url":"https://api.github.com/users/criteo-forks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/criteo-forks/jira-1","description":"Python JIRA Library is the easiest way to automate JIRA.","fork":true,"url":"https://api.github.com/repos/criteo-forks/jira-1","forks_url":"https://api.github.com/repos/criteo-forks/jira-1/forks","keys_url":"https://api.github.com/repos/criteo-forks/jira-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/criteo-forks/jira-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/criteo-forks/jira-1/teams","hooks_url":"https://api.github.com/repos/criteo-forks/jira-1/hooks","issue_events_url":"https://api.github.com/repos/criteo-forks/jira-1/issues/events{/number}","events_url":"https://api.github.com/repos/criteo-forks/jira-1/events","assignees_url":"https://api.github.com/repos/criteo-forks/jira-1/assignees{/user}","branches_url":"https://api.github.com/repos/criteo-forks/jira-1/branches{/branch}","tags_url":"https://api.github.com/repos/criteo-forks/jira-1/tags","blobs_url":"https://api.github.com/repos/criteo-forks/jira-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/criteo-forks/jira-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/criteo-forks/jira-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/criteo-forks/jira-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/criteo-forks/jira-1/statuses/{sha}","languages_url":"https://api.github.com/repos/criteo-forks/jira-1/languages","stargazers_url":"https://api.github.com/repos/criteo-forks/jira-1/stargazers","contributors_url":"https://api.github.com/repos/criteo-forks/jira-1/contributors","subscribers_url":"https://api.github.com/repos/criteo-forks/jira-1/subscribers","subscription_url":"https://api.github.com/repos/criteo-forks/jira-1/subscription","commits_url":"https://api.github.com/repos/criteo-forks/jira-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/criteo-forks/jira-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/criteo-forks/jira-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/criteo-forks/jira-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/criteo-forks/jira-1/contents/{+path}","compare_url":"https://api.github.com/repos/criteo-forks/jira-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/criteo-forks/jira-1/merges","archive_url":"https://api.github.com/repos/criteo-forks/jira-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/criteo-forks/jira-1/downloads","issues_url":"https://api.github.com/repos/criteo-forks/jira-1/issues{/number}","pulls_url":"https://api.github.com/repos/criteo-forks/jira-1/pulls{/number}","milestones_url":"https://api.github.com/repos/criteo-forks/jira-1/milestones{/number}","notifications_url":"https://api.github.com/repos/criteo-forks/jira-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/criteo-forks/jira-1/labels{/name}","releases_url":"https://api.github.com/repos/criteo-forks/jira-1/releases{/id}","deployments_url":"https://api.github.com/repos/criteo-forks/jira-1/deployments","created_at":"2017-11-09T15:06:35Z","updated_at":"2018-06-29T12:28:35Z","pushed_at":"2018-07-19T16:24:12Z","git_url":"git://github.com/criteo-forks/jira-1.git","ssh_url":"git@github.com:criteo-forks/jira-1.git","clone_url":"https://github.com/criteo-forks/jira-1.git","svn_url":"https://github.com/criteo-forks/jira-1","homepage":"https://github.com/pycontribs/jira","size":2512,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"bsd-2-clause","name":"BSD 2-Clause \"Simplified\" License","spdx_id":"BSD-2-Clause","url":"https://api.github.com/licenses/bsd-2-clause","node_id":"MDc6TGljZW5zZTQ="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"pycontribs:master","ref":"master","sha":"d0870c8de24422dacbb5885dfb8e003178787eac","user":{"login":"pycontribs","id":1846087,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NDYwODc=","avatar_url":"https://avatars1.githubusercontent.com/u/1846087?v=4","gravatar_id":"","url":"https://api.github.com/users/pycontribs","html_url":"https://github.com/pycontribs","followers_url":"https://api.github.com/users/pycontribs/followers","following_url":"https://api.github.com/users/pycontribs/following{/other_user}","gists_url":"https://api.github.com/users/pycontribs/gists{/gist_id}","starred_url":"https://api.github.com/users/pycontribs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pycontribs/subscriptions","organizations_url":"https://api.github.com/users/pycontribs/orgs","repos_url":"https://api.github.com/users/pycontribs/repos","events_url":"https://api.github.com/users/pycontribs/events{/privacy}","received_events_url":"https://api.github.com/users/pycontribs/received_events","type":"Organization","site_admin":false},"repo":{"id":21303988,"node_id":"MDEwOlJlcG9zaXRvcnkyMTMwMzk4OA==","name":"jira","full_name":"pycontribs/jira","owner":{"login":"pycontribs","id":1846087,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NDYwODc=","avatar_url":"https://avatars1.githubusercontent.com/u/1846087?v=4","gravatar_id":"","url":"https://api.github.com/users/pycontribs","html_url":"https://github.com/pycontribs","followers_url":"https://api.github.com/users/pycontribs/followers","following_url":"https://api.github.com/users/pycontribs/following{/other_user}","gists_url":"https://api.github.com/users/pycontribs/gists{/gist_id}","starred_url":"https://api.github.com/users/pycontribs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pycontribs/subscriptions","organizations_url":"https://api.github.com/users/pycontribs/orgs","repos_url":"https://api.github.com/users/pycontribs/repos","events_url":"https://api.github.com/users/pycontribs/events{/privacy}","received_events_url":"https://api.github.com/users/pycontribs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pycontribs/jira","description":"Python JIRA Library is the easiest way to automate JIRA.","fork":false,"url":"https://api.github.com/repos/pycontribs/jira","forks_url":"https://api.github.com/repos/pycontribs/jira/forks","keys_url":"https://api.github.com/repos/pycontribs/jira/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pycontribs/jira/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pycontribs/jira/teams","hooks_url":"https://api.github.com/repos/pycontribs/jira/hooks","issue_events_url":"https://api.github.com/repos/pycontribs/jira/issues/events{/number}","events_url":"https://api.github.com/repos/pycontribs/jira/events","assignees_url":"https://api.github.com/repos/pycontribs/jira/assignees{/user}","branches_url":"https://api.github.com/repos/pycontribs/jira/branches{/branch}","tags_url":"https://api.github.com/repos/pycontribs/jira/tags","blobs_url":"https://api.github.com/repos/pycontribs/jira/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pycontribs/jira/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pycontribs/jira/git/refs{/sha}","trees_url":"https://api.github.com/repos/pycontribs/jira/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pycontribs/jira/statuses/{sha}","languages_url":"https://api.github.com/repos/pycontribs/jira/languages","stargazers_url":"https://api.github.com/repos/pycontribs/jira/stargazers","contributors_url":"https://api.github.com/repos/pycontribs/jira/contributors","subscribers_url":"https://api.github.com/repos/pycontribs/jira/subscribers","subscription_url":"https://api.github.com/repos/pycontribs/jira/subscription","commits_url":"https://api.github.com/repos/pycontribs/jira/commits{/sha}","git_commits_url":"https://api.github.com/repos/pycontribs/jira/git/commits{/sha}","comments_url":"https://api.github.com/repos/pycontribs/jira/comments{/number}","issue_comment_url":"https://api.github.com/repos/pycontribs/jira/issues/comments{/number}","contents_url":"https://api.github.com/repos/pycontribs/jira/contents/{+path}","compare_url":"https://api.github.com/repos/pycontribs/jira/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pycontribs/jira/merges","archive_url":"https://api.github.com/repos/pycontribs/jira/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pycontribs/jira/downloads","issues_url":"https://api.github.com/repos/pycontribs/jira/issues{/number}","pulls_url":"https://api.github.com/repos/pycontribs/jira/pulls{/number}","milestones_url":"https://api.github.com/repos/pycontribs/jira/milestones{/number}","notifications_url":"https://api.github.com/repos/pycontribs/jira/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pycontribs/jira/labels{/name}","releases_url":"https://api.github.com/repos/pycontribs/jira/releases{/id}","deployments_url":"https://api.github.com/repos/pycontribs/jira/deployments","created_at":"2014-06-28T14:06:53Z","updated_at":"2018-08-21T18:40:00Z","pushed_at":"2018-08-21T18:39:57Z","git_url":"git://github.com/pycontribs/jira.git","ssh_url":"git@github.com:pycontribs/jira.git","clone_url":"https://github.com/pycontribs/jira.git","svn_url":"https://github.com/pycontribs/jira","homepage":"https://jira.readthedocs.io","size":2378,"stargazers_count":629,"watchers_count":629,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":349,"mirror_url":null,"archived":false,"open_issues_count":78,"license":{"key":"bsd-2-clause","name":"BSD 2-Clause \"Simplified\" License","spdx_id":"BSD-2-Clause","url":"https://api.github.com/licenses/bsd-2-clause","node_id":"MDc6TGljZW5zZTQ="},"forks":349,"open_issues":78,"watchers":629,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pycontribs/jira/pulls/616"},"html":{"href":"https://github.com/pycontribs/jira/pull/616"},"issue":{"href":"https://api.github.com/repos/pycontribs/jira/issues/616"},"comments":{"href":"https://api.github.com/repos/pycontribs/jira/issues/616/comments"},"review_comments":{"href":"https://api.github.com/repos/pycontribs/jira/pulls/616/comments"},"review_comment":{"href":"https://api.github.com/repos/pycontribs/jira/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pycontribs/jira/pulls/616/commits"},"statuses":{"href":"https://api.github.com/repos/pycontribs/jira/statuses/8f928d2a9531870d70daecf67c10700b557cf59f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ssbarnea"}}