27 lines
800 B
Python
27 lines
800 B
Python
from __future__ import annotations
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any, Optional, Mapping
|
|
|
|
|
|
class ICsrfService(ABC):
|
|
@abstractmethod
|
|
def issue(self, subject: Optional[str] = None) -> str:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def verify(self, token: str, expected_subject: Optional[str] = None) -> dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def extract(self, cookies: Mapping[str, str], headers: Mapping[str, str]) -> tuple[Optional[str], Optional[str]]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def verify_pair(
|
|
self,
|
|
cookie_token: Optional[str],
|
|
header_token: Optional[str],
|
|
expected_subject: Optional[str] = None,
|
|
) -> None:
|
|
raise NotImplementedError
|