Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Confluence cookies #17276

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ The following order is used for checking authentication credentials:

1. `oauth2`
2. `api_token`
3. `user_name` and `password`
4. Environment variable `CONFLUENCE_API_TOKEN`
5. Environment variable `CONFLUENCE_USERNAME` and `CONFLUENCE_PASSWORD`
3. `cookies`
4. `user_name` and `password`
5. Environment variable `CONFLUENCE_API_TOKEN`
6. Environment variable `CONFLUENCE_USERNAME` and `CONFLUENCE_PASSWORD`

For more on authenticating using OAuth 2.0, checkout:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ConfluenceReader(BaseReader):
base_url (str): 'base_url' for confluence cloud instance, this is suffixed with '/wiki', eg 'https://yoursite.atlassian.com/wiki'
cloud (bool): connecting to Confluence Cloud or self-hosted instance
api_token (str): Confluence API token, see https://confluence.atlassian.com/cloud/api-tokens-938839638.html
cookies (dict): Confluence cookies, see https://atlassian-python-api.readthedocs.io/index.html
user_name (str): Confluence username, used for basic auth. Must be used with `password`.
password (str): Confluence password, used for basic auth. Must be used with `user_name`.
client_args (dict): Additional keyword arguments to pass directly to the Atlassian Confluence client constructor, for example `{'backoff_and_retry': True}`.
Expand All @@ -43,6 +44,7 @@ def __init__(
oauth2: Optional[Dict] = None,
cloud: bool = True,
api_token: Optional[str] = None,
cookies: Optional[dict] = None,
user_name: Optional[str] = None,
password: Optional[str] = None,
client_args: Optional[dict] = None,
Expand Down Expand Up @@ -71,6 +73,10 @@ def __init__(
self.confluence = Confluence(
url=base_url, token=api_token, cloud=cloud, **client_args
)
elif cookies is not None:
self.confluence = Confluence(
url=base_url, cookies=cookies, cloud=cloud, **client_args
)
elif user_name is not None and password is not None:
self.confluence = Confluence(
url=base_url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ license = "MIT"
maintainers = ["zywilliamli"]
name = "llama-index-readers-confluence"
readme = "README.md"
version = "0.3.0"
version = "0.3.1"

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ def test_confluence_reader_with_api_token():
assert reader.confluence is not None


def test_confluence_reader_with_cookies():
reader = ConfluenceReader(
base_url="https://example.atlassian.net/wiki",
cookies={"key": "value"},
)
assert reader.confluence is not None


def test_confluence_reader_with_client_args():
with patch("atlassian.Confluence") as MockConstructor:
reader = ConfluenceReader(
Expand Down
Loading