mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 15:31:28 +00:00
21 lines
615 B
Python
21 lines
615 B
Python
"""GraphQL API for SelfPrivacy."""
|
|
# pylint: disable=too-few-public-methods
|
|
import typing
|
|
from strawberry.permission import BasePermission
|
|
from strawberry.types import Info
|
|
|
|
from selfprivacy_api.utils.auth import is_token_valid
|
|
|
|
|
|
class IsAuthenticated(BasePermission):
|
|
"""Is authenticated permission"""
|
|
|
|
message = "You must be authenticated to access this resource."
|
|
|
|
def has_permission(self, source: typing.Any, info: Info, **kwargs) -> bool:
|
|
return is_token_valid(
|
|
info.context["request"]
|
|
.headers.get("Authorization", "")
|
|
.replace("Bearer ", "")
|
|
)
|