Compare commits
No commits in common. "a987f47988db1d5a5160236f573c9e6e9ce19a29" and "adb53ec174f1d0a9b89725b8ca9bf2e8ece13e65" have entirely different histories.
a987f47988
...
adb53ec174
@ -11,10 +11,6 @@ body {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.container {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
|
@ -12,7 +12,7 @@ This module provides session management functionality including:
|
||||
from datetime import datetime, timedelta
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import Request, Response, WebSocket
|
||||
from fastapi import Request, Response
|
||||
|
||||
from ..db import Session, sql
|
||||
from ..util import passphrase
|
||||
@ -25,7 +25,7 @@ def expires() -> datetime:
|
||||
return datetime.now() + EXPIRES
|
||||
|
||||
|
||||
def infodict(request: Request | WebSocket, type: str) -> dict:
|
||||
def infodict(request: Request, type: str) -> dict:
|
||||
"""Extract client information from request."""
|
||||
return {
|
||||
"ip": request.client.host if request.client else "",
|
||||
|
@ -13,7 +13,7 @@ from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
import uuid7
|
||||
from fastapi import Cookie, FastAPI, Query, WebSocket, WebSocketDisconnect
|
||||
from fastapi import Cookie, FastAPI, Query, Request, WebSocket, WebSocketDisconnect
|
||||
from webauthn.helpers.exceptions import InvalidAuthenticationResponse
|
||||
|
||||
from passkey.fastapi import session
|
||||
@ -54,7 +54,7 @@ async def register_chat(
|
||||
|
||||
@app.websocket("/register")
|
||||
async def websocket_register_new(
|
||||
ws: WebSocket, user_name: str = Query(""), auth=Cookie(None)
|
||||
request: Request, ws: WebSocket, user_name: str = Query(""), auth=Cookie(None)
|
||||
):
|
||||
"""Register a new user and with a new passkey credential."""
|
||||
await ws.accept()
|
||||
@ -75,7 +75,7 @@ async def websocket_register_new(
|
||||
user_uuid=user_uuid,
|
||||
key=session_key(token),
|
||||
expires=datetime.now() + session.EXPIRES,
|
||||
info=infodict(ws, "authenticated"),
|
||||
info=infodict(request, "authenticated"),
|
||||
credential_uuid=credential.uuid,
|
||||
)
|
||||
|
||||
@ -142,7 +142,7 @@ async def websocket_register_add(ws: WebSocket, token: str | None = None):
|
||||
|
||||
|
||||
@app.websocket("/authenticate")
|
||||
async def websocket_authenticate(ws: WebSocket):
|
||||
async def websocket_authenticate(request: Request, ws: WebSocket):
|
||||
await ws.accept()
|
||||
origin = ws.headers.get("origin")
|
||||
try:
|
||||
@ -161,7 +161,7 @@ async def websocket_authenticate(ws: WebSocket):
|
||||
assert stored_cred.uuid is not None
|
||||
token = await create_session(
|
||||
user_uuid=stored_cred.user_uuid,
|
||||
info=infodict(ws, "auth"),
|
||||
info=infodict(request, "auth"),
|
||||
credential_uuid=stored_cred.uuid,
|
||||
)
|
||||
|
||||
|
@ -11,7 +11,6 @@ import json
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
import uuid7
|
||||
from webauthn import (
|
||||
generate_authentication_options,
|
||||
generate_registration_options,
|
||||
@ -113,7 +112,7 @@ class Passkey:
|
||||
self,
|
||||
response_json: dict | str,
|
||||
expected_challenge: bytes,
|
||||
user_uuid: UUID,
|
||||
user_id: UUID,
|
||||
origin: str | None = None,
|
||||
) -> Credential:
|
||||
"""
|
||||
@ -134,9 +133,8 @@ class Passkey:
|
||||
expected_rp_id=self.rp_id,
|
||||
)
|
||||
return Credential(
|
||||
uuid=uuid7.create(),
|
||||
credential_id=credential.raw_id,
|
||||
user_uuid=user_uuid,
|
||||
user_id=user_id,
|
||||
aaguid=UUID(registration.aaguid),
|
||||
public_key=registration.credential_public_key,
|
||||
sign_count=registration.sign_count,
|
||||
|
Loading…
x
Reference in New Issue
Block a user