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

Feature/confluence oauth #3477

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0fdaa93
first cut at slack oauth flow
rkuo-danswer Dec 3, 2024
3cd5e09
Merge branch 'main' of https://github.com/danswer-ai/danswer into fea…
rkuo-danswer Dec 3, 2024
7613871
fix usage of hooks
rkuo-danswer Dec 3, 2024
e4de2a8
fix button spacing
rkuo-danswer Dec 4, 2024
8ca9118
add additional error logging
rkuo-danswer Dec 4, 2024
ec08bab
no dev redirect
rkuo-danswer Dec 4, 2024
cf32cef
early cut at google drive oauth
rkuo-danswer Dec 5, 2024
72f956a
second pass
rkuo-danswer Dec 6, 2024
a0d1ce6
switch to production uri's
rkuo-danswer Dec 7, 2024
db20d0d
Merge branch 'main' of https://github.com/danswer-ai/danswer into fea…
rkuo-danswer Dec 7, 2024
e8468b1
try handling oauth_interactive differently
rkuo-danswer Dec 7, 2024
b754175
pass through client id and secret if uploaded
LostVector Dec 7, 2024
88cb253
fix call
LostVector Dec 7, 2024
4cf3e67
fix test
LostVector Dec 7, 2024
d8c5b4e
Merge branch 'main' of https://github.com/danswer-ai/danswer into fea…
LostVector Dec 8, 2024
4b5a022
temporarily disable check for testing
LostVector Dec 8, 2024
b1f6026
Revert "temporarily disable check for testing"
LostVector Dec 8, 2024
2d8706b
support visibility in test
Dec 11, 2024
71230ea
missed file
Dec 11, 2024
06ce1e7
Merge branch 'main' of https://github.com/danswer-ai/danswer into fea…
Dec 11, 2024
983dd45
Merge branch 'main' of https://github.com/danswer-ai/danswer into fea…
Dec 12, 2024
8935c39
first cut at confluence oauth
Dec 15, 2024
ac378f4
Merge branch 'main' of https://github.com/danswer-ai/danswer into fea…
LostVector Dec 17, 2024
f168873
work in progress
LostVector Dec 18, 2024
f7d6281
work in progress
Dec 18, 2024
da9647f
work in progress
Dec 19, 2024
48fbbfd
work in progress
Dec 19, 2024
588f5d9
work in progress
Dec 21, 2024
f5d036f
first cut at distributed locking
Dec 30, 2024
85d94dc
Merge branch 'main' of https://github.com/danswer-ai/danswer into fea…
LostVector Dec 30, 2024
249266c
Merge branch 'main' of https://github.com/onyx-dot-app/onyx into feat…
Jan 16, 2025
5544ce1
WIP to make test work
Jan 16, 2025
c20ef38
add some dev mode affordances and gate usage of redis behind dynamic …
Jan 16, 2025
12c17b4
mypy and credentials provider fixes
Jan 16, 2025
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
12 changes: 8 additions & 4 deletions backend/ee/onyx/configs/app_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@

OAUTH_SLACK_CLIENT_ID = os.environ.get("OAUTH_SLACK_CLIENT_ID", "")
OAUTH_SLACK_CLIENT_SECRET = os.environ.get("OAUTH_SLACK_CLIENT_SECRET", "")
OAUTH_CONFLUENCE_CLIENT_ID = os.environ.get("OAUTH_CONFLUENCE_CLIENT_ID", "")
OAUTH_CONFLUENCE_CLIENT_SECRET = os.environ.get("OAUTH_CONFLUENCE_CLIENT_SECRET", "")
OAUTH_JIRA_CLIENT_ID = os.environ.get("OAUTH_JIRA_CLIENT_ID", "")
OAUTH_JIRA_CLIENT_SECRET = os.environ.get("OAUTH_JIRA_CLIENT_SECRET", "")
OAUTH_CONFLUENCE_CLOUD_CLIENT_ID = os.environ.get(
"OAUTH_CONFLUENCE_CLOUD_CLIENT_ID", ""
)
OAUTH_CONFLUENCE_CLOUD_CLIENT_SECRET = os.environ.get(
"OAUTH_CONFLUENCE_CLOUD_CLIENT_SECRET", ""
)
OAUTH_JIRA_CLOUD_CLIENT_ID = os.environ.get("OAUTH_JIRA_CLOUD_CLIENT_ID", "")
OAUTH_JIRA_CLOUD_CLIENT_SECRET = os.environ.get("OAUTH_JIRA_CLOUD_CLIENT_SECRET", "")
OAUTH_GOOGLE_DRIVE_CLIENT_ID = os.environ.get("OAUTH_GOOGLE_DRIVE_CLIENT_ID", "")
OAUTH_GOOGLE_DRIVE_CLIENT_SECRET = os.environ.get(
"OAUTH_GOOGLE_DRIVE_CLIENT_SECRET", ""
Expand Down
11 changes: 9 additions & 2 deletions backend/ee/onyx/external_permissions/confluence/doc_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
from onyx.access.models import DocExternalAccess
from onyx.access.models import ExternalAccess
from onyx.connectors.confluence.connector import ConfluenceConnector
from onyx.connectors.confluence.onyx_confluence import (
get_user_email_from_username__server,
)
from onyx.connectors.confluence.onyx_confluence import OnyxConfluence
from onyx.connectors.confluence.utils import get_user_email_from_username__server
from onyx.connectors.credentials_provider import OnyxDBCredentialsProvider
from onyx.connectors.models import SlimDocument
from onyx.db.models import ConnectorCredentialPair
from onyx.utils.logger import setup_logger
Expand Down Expand Up @@ -334,6 +337,7 @@ def _fetch_all_page_restrictions(


def confluence_doc_sync(
tenant_id: str | None,
cc_pair: ConnectorCredentialPair,
) -> list[DocExternalAccess]:
"""
Expand All @@ -346,7 +350,10 @@ def confluence_doc_sync(
confluence_connector = ConfluenceConnector(
**cc_pair.connector.connector_specific_config
)
confluence_connector.load_credentials(cc_pair.credential.credential_json)

# confluence_connector.load_credentials(cc_pair.credential.credential_json)
provider = OnyxDBCredentialsProvider(tenant_id, "confluence", cc_pair.credential_id)
confluence_connector.set_credentials_provider(provider)

is_cloud = cc_pair.connector.connector_specific_config.get("is_cloud", False)

Expand Down
40 changes: 33 additions & 7 deletions backend/ee/onyx/external_permissions/confluence/group_sync.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from ee.onyx.db.external_perm import ExternalUserGroup
from ee.onyx.external_permissions.confluence.constants import ALL_CONF_EMAILS_GROUP_NAME
from onyx.connectors.confluence.onyx_confluence import build_confluence_client
from onyx.connectors.confluence.onyx_confluence import (
get_user_email_from_username__server,
)
from onyx.connectors.confluence.onyx_confluence import OnyxConfluence
from onyx.connectors.confluence.utils import get_user_email_from_username__server
from onyx.connectors.credentials_provider import OnyxDBCredentialsProvider
from onyx.db.models import ConnectorCredentialPair
from onyx.utils.logger import setup_logger

Expand Down Expand Up @@ -42,13 +44,37 @@ def _build_group_member_email_map(


def confluence_group_sync(
tenant_id: str | None,
cc_pair: ConnectorCredentialPair,
) -> list[ExternalUserGroup]:
confluence_client = build_confluence_client(
credentials=cc_pair.credential.credential_json,
is_cloud=cc_pair.connector.connector_specific_config.get("is_cloud", False),
wiki_base=cc_pair.connector.connector_specific_config["wiki_base"],
)
# confluence_connector = ConfluenceConnector(
# **cc_pair.connector.connector_specific_config
# )

provider = OnyxDBCredentialsProvider(tenant_id, "confluence", cc_pair.credential_id)
is_cloud = cc_pair.connector.connector_specific_config.get("is_cloud", False)
wiki_base: str = cc_pair.connector.connector_specific_config["wiki_base"]
url = wiki_base.rstrip("/")

probe_kwargs = {
"max_backoff_retries": 6,
"max_backoff_seconds": 10,
}

final_kwargs = {
"max_backoff_retries": 10,
"max_backoff_seconds": 60,
}

confluence_client = OnyxConfluence(is_cloud, url, provider)
confluence_client._probe_connection(**probe_kwargs)
confluence_client._initialize_connection(**final_kwargs)

# confluence_client = build_confluence_client(
# credentials=cc_pair.credential.credential_json,
# is_cloud=cc_pair.connector.connector_specific_config.get("is_cloud", False),
# wiki_base=cc_pair.connector.connector_specific_config["wiki_base"],
# )

group_member_email_map = _build_group_member_email_map(
confluence_client=confluence_client,
Expand Down
1 change: 1 addition & 0 deletions backend/ee/onyx/external_permissions/gmail/doc_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def _get_slim_doc_generator(


def gmail_doc_sync(
tenant_id: str | None,
cc_pair: ConnectorCredentialPair,
) -> list[DocExternalAccess]:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def _get_permissions_from_slim_doc(


def gdrive_doc_sync(
tenant_id: str | None,
cc_pair: ConnectorCredentialPair,
) -> list[DocExternalAccess]:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


def gdrive_group_sync(
tenant_id: str | None,
cc_pair: ConnectorCredentialPair,
) -> list[ExternalUserGroup]:
google_drive_connector = GoogleDriveConnector(
Expand Down
1 change: 1 addition & 0 deletions backend/ee/onyx/external_permissions/slack/doc_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def _fetch_channel_permissions(


def slack_doc_sync(
tenant_id: str | None,
cc_pair: ConnectorCredentialPair,
) -> list[DocExternalAccess]:
"""
Expand Down
2 changes: 2 additions & 0 deletions backend/ee/onyx/external_permissions/sync_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
# Defining the input/output types for the sync functions
DocSyncFuncType = Callable[
[
str | None,
ConnectorCredentialPair,
],
list[DocExternalAccess],
]

GroupSyncFuncType = Callable[
[
str | None,
ConnectorCredentialPair,
],
list[ExternalUserGroup],
Expand Down
6 changes: 5 additions & 1 deletion backend/ee/onyx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)
from ee.onyx.server.manage.standard_answer import router as standard_answer_router
from ee.onyx.server.middleware.tenant_tracking import add_tenant_id_middleware
from ee.onyx.server.oauth import router as oauth_router
from ee.onyx.server.oauth.api import router as oauth_router
from ee.onyx.server.query_and_chat.chat_backend import (
router as chat_router,
)
Expand Down Expand Up @@ -144,4 +144,8 @@ def get_application() -> FastAPI:
# environment variable. Used to automate deployment for multiple environments.
seed_db()

# for debugging discovered routes
# for route in application.router.routes:
# print(f"Path: {route.path}, Methods: {route.methods}")

return application
Loading
Loading