From 3e632fcfa4d8f6b1da1848d7afd46641b8184c03 Mon Sep 17 00:00:00 2001 From: EugeneP Date: Mon, 4 Dec 2023 16:10:48 +0200 Subject: [PATCH 1/3] Confluence connector improvements --- confluence/.env-template | 2 +- confluence/README.md | 6 ++++-- confluence/dev/load_data.py | 4 ++-- confluence/provider/client.py | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/confluence/.env-template b/confluence/.env-template index a85d3a002..7c2fadf07 100644 --- a/confluence/.env-template +++ b/confluence/.env-template @@ -1,5 +1,5 @@ CONFLUENCE_USER= -CONFLUENCE_PASSWORD= +CONFLUENCE_API_TOKEN= CONFLUENCE_PRODUCT_URL=https://sample.atlassian.net CONFLUENCE_SPACE_NAME= CONFLUENCE_SEARCH_LIMIT=10 diff --git a/confluence/README.md b/confluence/README.md index 70e0dfbad..d3f58d4de 100644 --- a/confluence/README.md +++ b/confluence/README.md @@ -13,12 +13,14 @@ This connector requires the following environment variables: ``` CONFLUENCE_USER -CONFLUENCE_PASSWORD +CONFLUENCE_API_TOKEN CONFLUENCE_PRODUCT_URL CONFLUENCE_SPACE_NAME ``` -The user and password combination should be a user email address and an API token pair. +The user and api token combination should be a user email address and an API token pair. +The API token can be generated by logging into Confluence and going +to the API tokens [page](https://id.atlassian.com/manage-profile/security/api-tokens). The product URL should be the URL for the Confluence wiki, including the https:// scheme. The space name should be the name of a single space in your wiki. diff --git a/confluence/dev/load_data.py b/confluence/dev/load_data.py index b2d89730f..501d5516b 100644 --- a/confluence/dev/load_data.py +++ b/confluence/dev/load_data.py @@ -9,8 +9,8 @@ confluence = Confluence( url=os.environ.get("CONFLUENCE_PRODUCT_URL"), - username=os.environ.get("CONFLUENCE_CLIENT_USER"), - password=os.environ.get("CONFLUENCE_CLIENT_PASS"), + username=os.environ.get("CONFLUENCE_USER"), + password=os.environ.get("CONFLUENCE_API_TOKEN"), ) space = os.environ.get("CONFLUENCE_SPACE_NAME") diff --git a/confluence/provider/client.py b/confluence/provider/client.py index b69d653af..a26f33bb8 100644 --- a/confluence/provider/client.py +++ b/confluence/provider/client.py @@ -1,6 +1,6 @@ +import asyncio import functools -import asyncio from atlassian import Confluence from flask import current_app as app @@ -77,7 +77,7 @@ def get_client(): assert (url := app.config.get("PRODUCT_URL")), "CONFLUENCE_PRODUCT_URL must be set" assert (user := app.config.get("USER")), "CONFLUENCE_USER must be set" - assert (password := app.config.get("PASSWORD")), "CONFLUENCE_PASSWORD must be set" + assert (password := app.config.get("API_TOKEN")), "CONFLUENCE_API_TOKEN must be set" assert (space := app.config.get("SPACE_NAME")), "CONFLUENCE_SPACE_NAME must be set" search_limit = app.config.get("SEARCH_LIMIT", 10) client = ConfluenceClient(url, user, password, space, search_limit) From 086e3669c3b94afd64a99b632e20bb9b78f031d1 Mon Sep 17 00:00:00 2001 From: EugeneP Date: Mon, 4 Dec 2023 17:36:49 +0200 Subject: [PATCH 2/3] Confluence connector improvements --- confluence/provider/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/confluence/provider/client.py b/confluence/provider/client.py index a26f33bb8..2c3040e89 100644 --- a/confluence/provider/client.py +++ b/confluence/provider/client.py @@ -10,12 +10,12 @@ class ConfluenceClient: - def __init__(self, url, user, password, space, search_limit=10): + def __init__(self, url, user, api_token, space, search_limit=10): try: self.confluence = Confluence( url=url, username=user, - password=password, + password=api_token, ) self.space = space self.search_limit = search_limit @@ -77,9 +77,9 @@ def get_client(): assert (url := app.config.get("PRODUCT_URL")), "CONFLUENCE_PRODUCT_URL must be set" assert (user := app.config.get("USER")), "CONFLUENCE_USER must be set" - assert (password := app.config.get("API_TOKEN")), "CONFLUENCE_API_TOKEN must be set" + assert (api_token := app.config.get("API_TOKEN")), "CONFLUENCE_API_TOKEN must be set" assert (space := app.config.get("SPACE_NAME")), "CONFLUENCE_SPACE_NAME must be set" search_limit = app.config.get("SEARCH_LIMIT", 10) - client = ConfluenceClient(url, user, password, space, search_limit) + client = ConfluenceClient(url, user, api_token, space, search_limit) return client From 3d95e16282e8f5e0665471a9478212d9d9610f38 Mon Sep 17 00:00:00 2001 From: EugeneP Date: Mon, 4 Dec 2023 17:41:41 +0200 Subject: [PATCH 3/3] Confluence connector improvements --- confluence/provider/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/confluence/provider/client.py b/confluence/provider/client.py index 2c3040e89..f68ba0307 100644 --- a/confluence/provider/client.py +++ b/confluence/provider/client.py @@ -77,7 +77,9 @@ def get_client(): assert (url := app.config.get("PRODUCT_URL")), "CONFLUENCE_PRODUCT_URL must be set" assert (user := app.config.get("USER")), "CONFLUENCE_USER must be set" - assert (api_token := app.config.get("API_TOKEN")), "CONFLUENCE_API_TOKEN must be set" + assert ( + api_token := app.config.get("API_TOKEN") + ), "CONFLUENCE_API_TOKEN must be set" assert (space := app.config.get("SPACE_NAME")), "CONFLUENCE_SPACE_NAME must be set" search_limit = app.config.get("SEARCH_LIMIT", 10) client = ConfluenceClient(url, user, api_token, space, search_limit)