This commit is contained in:
2025-09-26 14:45:27 -03:00
parent eeeccaaaa8
commit 1b6e4b7b5e
13 changed files with 131 additions and 212 deletions

View File

@@ -1,4 +1,5 @@
import time
from dataclasses import dataclass
from authlib.oauth2.rfc6749 import (
AuthorizationCodeMixin,
@@ -8,6 +9,17 @@ from authlib.oauth2.rfc6749 import (
from layercake.dateutils import fromisoformat, now
@dataclass(frozen=True)
class User:
id: str
name: str
email: str
email_verified: bool = False
def get_user_id(self):
return self.id
class OAuth2AuthorizationCode(AuthorizationCodeMixin):
def __init__(
self,
@@ -75,8 +87,8 @@ class OAuth2Token(TokenMixin):
self.access_token = access_token
self.refresh_token = refresh_token
def get_user(self) -> dict:
return self.user
def get_user(self) -> User:
return User(**self.user)
def check_client(self, client: ClientMixin) -> bool:
return self.client_id == client.get_client_id()