Skip to content
Open
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
21 changes: 20 additions & 1 deletion skyvern/forge/sdk/services/org_auth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,26 @@ async def get_current_org_with_authentication(
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid credentials",
)
return await _authenticate_helper(authorization)
token = authorization.split(" ")[1]
if not app.authentication_function:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid authentication method",
)
organization = await app.authentication_function(token)
if not organization:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid credentials",
)

# set organization_id in skyvern context and log context
context = skyvern_context.current()
if context:
context.organization_id = organization.organization_id
context.organization_name = organization.organization_name

return organization


async def _authenticate_helper(authorization: str) -> Organization:
Expand Down