Skip to content

Commit 9150259

Browse files
authored
Merge pull request #815 from airweave-ai/hotfix/oauth_endpoint
hotfix: pass validated config to source authentication validation methods
2 parents bf6966f + 8511ce5 commit 9150259

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

backend/airweave/core/source_connection_service.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ async def _create_with_direct_auth(
345345
)
346346

347347
# Validate credentials with source
348-
await self._validate_direct_auth(db, source, validated_auth, ctx)
348+
await self._validate_direct_auth(db, source, validated_auth, validated_config, ctx)
349349

350350
async with UnitOfWork(db) as uow:
351351
# Get collection
@@ -552,14 +552,16 @@ async def _create_with_oauth_token(
552552
if obj_in.authentication.expires_at:
553553
oauth_creds["expires_at"] = obj_in.authentication.expires_at.isoformat()
554554

555-
# Validate token
556-
await self._validate_oauth_token(db, source, obj_in.authentication.access_token, ctx)
557-
558555
# Validate config
559556
validated_config = await self._validate_config_fields(
560557
db, obj_in.short_name, obj_in.config, ctx
561558
)
562559

560+
# Validate token
561+
await self._validate_oauth_token(
562+
db, source, obj_in.authentication.access_token, validated_config, ctx
563+
)
564+
563565
async with UnitOfWork(db) as uow:
564566
# Get collection
565567
collection = await self._get_collection(uow.session, obj_in.readable_collection_id, ctx)
@@ -1036,6 +1038,7 @@ async def complete_oauth_callback(
10361038
db,
10371039
await crud.source.get_by_short_name(db, short_name=init_session.short_name),
10381040
token_response.access_token,
1041+
None,
10391042
ctx,
10401043
)
10411044

backend/airweave/core/source_connection_service_helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from airweave.models.sync import Sync
3434
from airweave.models.sync_job import SyncJob
3535
from airweave.platform.auth.services import oauth2_service
36+
from airweave.platform.configs._base import ConfigValues
3637
from airweave.platform.configs.auth import AuthConfig
3738
from airweave.platform.locator import resource_locator
3839
from airweave.platform.temporal.schedule_service import temporal_schedule_service
@@ -232,12 +233,13 @@ async def validate_direct_auth(
232233
db: AsyncSession,
233234
source: schemas.Source,
234235
auth_fields: AuthConfig,
236+
config_fields: Optional[ConfigValues],
235237
ctx: ApiContext,
236238
) -> Dict[str, Any]:
237239
"""Validate direct authentication credentials."""
238240
try:
239241
source_cls = resource_locator.get_source(source)
240-
source_instance = await source_cls.create(auth_fields, config=None)
242+
source_instance = await source_cls.create(auth_fields, config=config_fields)
241243
source_instance.set_logger(ctx.logger)
242244

243245
if hasattr(source_instance, "validate"):
@@ -262,12 +264,15 @@ async def validate_oauth_token(
262264
db: AsyncSession,
263265
source: schemas.Source,
264266
access_token: str,
267+
config_fields: Optional[ConfigValues],
265268
ctx: ApiContext,
266269
) -> Dict[str, Any]:
267270
"""Validate OAuth access token."""
268271
try:
269272
source_cls = resource_locator.get_source(source)
270-
source_instance = await source_cls.create(access_token=access_token, config=None)
273+
source_instance = await source_cls.create(
274+
access_token=access_token, config=config_fields
275+
)
271276
source_instance.set_logger(ctx.logger)
272277

273278
if hasattr(source_instance, "validate"):

backend/airweave/platform/sources/linear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,4 +952,4 @@ async def validate(self) -> bool:
952952
return False
953953
except Exception as e:
954954
self.logger.error(f"Unexpected error during Linear validation: {e}")
955-
return False
955+
return False

0 commit comments

Comments
 (0)