Skip to content

Commit 31e637b

Browse files
authored
fix: detect Confluence Cloud instances in Multi-Cloud OAuth mode (sooperset#586)
* fix: detect Confluence Cloud instances in Multi-Cloud OAuth mode When using Multi-Cloud OAuth with BYOT (Bring Your Own Token) flow, Confluence's is_cloud property incorrectly returned false because it only checked the URL pattern. In Multi-Cloud setups, the URL may be None or empty as requests use api.atlassian.com with a cloud_id. This fix ensures that OAuth configurations with a cloud_id are always treated as Cloud instances, enabling proper v2 API adapter activation and preventing authentication failures. The implementation matches the fix already applied to Jira in PR sooperset#581. Reported-by: Ian Github-Issue: sooperset#580 * chore: revert uv.lock changes from previous commit Reverts unintended uv.lock changes that were included in the fix for Confluence Cloud detection in Multi-Cloud OAuth mode.
1 parent 77095be commit 31e637b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/mcp_atlassian/confluence/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/confluence/test_config.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,27 @@ def test_from_env_proxy_settings():
159159
config.socks_proxy == "socks5://user:[email protected]:1080"
160160
)
161161
assert config.no_proxy == "localhost,127.0.0.1,.internal.example.com"
162+
163+
164+
def test_is_cloud_oauth_with_cloud_id():
165+
"""Test that is_cloud returns True for OAuth with cloud_id regardless of URL."""
166+
from mcp_atlassian.utils.oauth import BYOAccessTokenOAuthConfig
167+
168+
# OAuth with cloud_id and no URL - should be Cloud
169+
oauth_config = BYOAccessTokenOAuthConfig(
170+
cloud_id="test-cloud-id", access_token="test-token"
171+
)
172+
config = ConfluenceConfig(
173+
url=None, # URL can be None in Multi-Cloud OAuth mode
174+
auth_type="oauth",
175+
oauth_config=oauth_config,
176+
)
177+
assert config.is_cloud is True
178+
179+
# OAuth with cloud_id and server URL - should still be Cloud
180+
config = ConfluenceConfig(
181+
url="https://confluence.example.com", # Server-like URL
182+
auth_type="oauth",
183+
oauth_config=oauth_config,
184+
)
185+
assert config.is_cloud is True

0 commit comments

Comments
 (0)