mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 05:11:53 +09:00
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
import json
|
|
from pydantic import BaseModel
|
|
from lib.prompt.get_sso_list import get_sso_list_task
|
|
|
|
from lib.browser_use_utils.run_task import run_task
|
|
|
|
|
|
NOT_FOUND_LOGIN_PAGE = 0
|
|
FOUND_LOGIN_PAGE = 1
|
|
|
|
class FindLoginPageResponse(BaseModel):
|
|
status: int = NOT_FOUND_LOGIN_PAGE # 0 if not found, 1 if found
|
|
msg: str | None = None
|
|
url: str | None = None
|
|
sso_list: list[str] = [] # List of SSO providers found on the login page
|
|
|
|
async def get_sso_list(target_url) -> tuple[bool, str | FindLoginPageResponse | None]:
|
|
|
|
task = get_sso_list_task
|
|
ReturnModel = FindLoginPageResponse
|
|
success, response = await run_task(target_url, ReturnModel, task)
|
|
if not success:
|
|
return False, response
|
|
if isinstance(response, str):
|
|
return False, response
|
|
if isinstance(response, FindLoginPageResponse):
|
|
if response.status == FOUND_LOGIN_PAGE:
|
|
if not response.sso_list:
|
|
response.msg = "로그인 페이지는 찾았지만 SSO 제공자가 없습니다."
|
|
else:
|
|
response.msg = "로그인 페이지와 SSO 제공자를 찾았습니다."
|
|
else:
|
|
response.msg = "로그인 페이지를 찾지 못했습니다."
|
|
else:
|
|
return False, "응답 형식이 올바르지 않습니다. FindLoginPageResponse가 아닙니다."
|
|
|
|
return True, response
|
|
|
|
|
|
|
|
|