21 lines
624 B
Python
21 lines
624 B
Python
from fastapi import HTTPException
|
|
|
|
|
|
class AuthenticationError(HTTPException):
|
|
def __init__(self, detail: str = "Could not validate credentials"):
|
|
super().__init__(
|
|
status_code=401,
|
|
detail=detail,
|
|
headers={"WWW-Authenticate": "Bearer"},
|
|
)
|
|
|
|
|
|
class AuthorizationError(HTTPException):
|
|
def __init__(self, detail: str = "Insufficient permissions"):
|
|
super().__init__(status_code=403, detail=detail)
|
|
|
|
|
|
class NotFoundError(HTTPException):
|
|
def __init__(self, resource: str = "Resource"):
|
|
super().__init__(status_code=404, detail=f"{resource} not found")
|