40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from app.core.security import token_urlsafe
|
|
|
|
|
|
class PasskeyProvider:
|
|
def registration_options(self, display_name: str | None = None) -> dict:
|
|
raise NotImplementedError
|
|
|
|
def verify_registration(self, payload: dict) -> dict:
|
|
raise NotImplementedError
|
|
|
|
def login_options(self) -> dict:
|
|
raise NotImplementedError
|
|
|
|
def verify_login(self, payload: dict) -> dict:
|
|
raise NotImplementedError
|
|
|
|
|
|
class DevelopmentPasskeyProvider(PasskeyProvider):
|
|
"""Development-only passkey-shaped adapter.
|
|
|
|
It preserves the API contract and UI flow without claiming production WebAuthn.
|
|
"""
|
|
|
|
def registration_options(self, display_name: str | None = None) -> dict:
|
|
return {"challenge": token_urlsafe(24), "display_name": display_name, "development_only": True}
|
|
|
|
def verify_registration(self, payload: dict) -> dict:
|
|
return {"verified": True, "trust_level": "passkey_ready", "development_only": True}
|
|
|
|
def login_options(self) -> dict:
|
|
return {"challenge": token_urlsafe(24), "development_only": True}
|
|
|
|
def verify_login(self, payload: dict) -> dict:
|
|
return {"verified": True, "development_only": True}
|
|
|
|
|
|
passkey_provider: PasskeyProvider = DevelopmentPasskeyProvider()
|