39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
|
|
import asyncio
|
|
|
|
|
|
async def sso_login(page, timeout=15000):
|
|
"""Login to Authentik SSO with Yanis credentials"""
|
|
try:
|
|
# Check if already on Authentik login
|
|
if "authentik" in page.url or "flow" in page.url:
|
|
pass
|
|
else:
|
|
# Navigate to a protected page to trigger SSO
|
|
await page.goto("https://weval-consulting.com/crm.html", timeout=timeout)
|
|
await page.wait_for_timeout(2000)
|
|
|
|
# Fill Authentik login form
|
|
uid = page.locator('input[name="uidField"], input[name="uid_field"], #id_uid_field, input[type="text"]').first
|
|
if await uid.is_visible():
|
|
await uid.fill("Yacineutt")
|
|
# Click continue/next
|
|
btn = page.locator('button[type="submit"], .pf-c-button--primary, button:has-text("Continuer"), button:has-text("Log in")').first
|
|
if await btn.is_visible():
|
|
await btn.click()
|
|
await page.wait_for_timeout(2000)
|
|
|
|
# Fill password
|
|
pwd = page.locator('input[name="password"], input[type="password"], #id_password').first
|
|
if await pwd.is_visible():
|
|
await pwd.fill("YacineWeval2026")
|
|
btn2 = page.locator('button[type="submit"], .pf-c-button--primary, button:has-text("Continuer"), button:has-text("Log in")').first
|
|
if await btn2.is_visible():
|
|
await btn2.click()
|
|
await page.wait_for_timeout(3000)
|
|
|
|
return True
|
|
except Exception as e:
|
|
print(f"SSO login error: {e}")
|
|
return False
|