Skip to content

Commit 3b07fd3

Browse files
authored
fix: use accountId parameter for user lookups in Jira Cloud OAuth mode (sooperset#581)
- Fix is_cloud property to correctly identify Multi-Cloud OAuth as Cloud instance - OAuth with cloud_id now always returns True for is_cloud check - This ensures user lookups use accountId parameter instead of username - Also fixes Confluence v2 adapter issues in Multi-Cloud OAuth mode - Add test coverage for OAuth cloud detection Reported-by: Muhammad Ali Reported-by: Ian Github-Issue: sooperset#560 Github-Issue: sooperset#580
1 parent aaeb824 commit 3b07fd3

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/mcp_atlassian/jira/config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@ def is_cloud(self) -> bool:
4545
True if this is a cloud instance (atlassian.net), False otherwise.
4646
Localhost URLs are always considered non-cloud (Server/Data Center).
4747
"""
48-
return is_atlassian_cloud_url(self.url)
48+
# Multi-Cloud OAuth mode: URL might be None, but we use api.atlassian.com
49+
if (
50+
self.auth_type == "oauth"
51+
and self.oauth_config
52+
and self.oauth_config.cloud_id
53+
):
54+
# OAuth with cloud_id uses api.atlassian.com which is always Cloud
55+
return True
56+
57+
# For other auth types, check the URL
58+
return is_atlassian_cloud_url(self.url) if self.url else False
4959

5060
@property
5161
def verify_ssl(self) -> bool:

tests/unit/jira/test_config.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,27 @@ def test_from_env_proxy_settings():
179179
assert config.https_proxy == "https://jira-proxy.example.com:8443"
180180
assert config.socks_proxy == "socks5://user:[email protected]:1080"
181181
assert config.no_proxy == "localhost,127.0.0.1,.internal.example.com"
182+
183+
184+
def test_is_cloud_oauth_with_cloud_id():
185+
"""Test that is_cloud returns True for OAuth with cloud_id regardless of URL."""
186+
from mcp_atlassian.utils.oauth import BYOAccessTokenOAuthConfig
187+
188+
# OAuth with cloud_id and no URL - should be Cloud
189+
oauth_config = BYOAccessTokenOAuthConfig(
190+
cloud_id="test-cloud-id", access_token="test-token"
191+
)
192+
config = JiraConfig(
193+
url=None, # URL can be None in Multi-Cloud OAuth mode
194+
auth_type="oauth",
195+
oauth_config=oauth_config,
196+
)
197+
assert config.is_cloud is True
198+
199+
# OAuth with cloud_id and server URL - should still be Cloud
200+
config = JiraConfig(
201+
url="https://jira.example.com", # Server-like URL
202+
auth_type="oauth",
203+
oauth_config=oauth_config,
204+
)
205+
assert config.is_cloud is True

0 commit comments

Comments
 (0)