diff --git a/auth_lib/fastapi.py b/auth_lib/fastapi.py index d14affa..23b920d 100644 --- a/auth_lib/fastapi.py +++ b/auth_lib/fastapi.py @@ -65,7 +65,7 @@ def __init__( ) self.scopes = scopes - def _except_authorization(self): + def _except_not_authorized(self): if self.auto_error: raise HTTPException( status_code=HTTP_401_UNAUTHORIZED, detail="Not authorized" @@ -73,7 +73,7 @@ def _except_authorization(self): else: return None - def _except_authentificated(self): + def _except_not_authentificated(self): if self.auto_error: raise HTTPException( status_code=HTTP_403_FORBIDDEN, detail="Not authenticated" @@ -85,7 +85,7 @@ async def _get_session(self, token: str | None) -> dict[str, Any] | None: if not token and self.allow_none: return None if not token: - return self._except_authorization() + return self._except_not_authorized() return await AsyncAuthLib(auth_url=self.auth_url).check_token(token) async def _get_userdata( @@ -94,7 +94,7 @@ async def _get_userdata( if not token and self.allow_none: return None if not token: - return self._except_authorization() + return self._except_not_authorized() if self.enable_userdata: return await AsyncAuthLib(userdata_url=self.userdata_url).get_user_data( token, user_id @@ -108,7 +108,7 @@ async def __call__( token = request.headers.get("Authorization") result = await self._get_session(token) if result is None: - return self._except_authorization() + return self._except_not_authorized() if self.enable_userdata: user_data_info = await self._get_userdata(token, result["id"]) result["userdata"] = [] @@ -119,5 +119,5 @@ async def __call__( ) required_scopes = set([scope.lower() for scope in self.scopes]) if required_scopes - session_scopes: - self._except_authentificated() + self._except_not_authentificated() return result