refactor(tokens-repo): delete is_token_valid from auth utils

This commit is contained in:
Houkime 2022-12-26 15:20:58 +00:00
parent 7d9bccf4ec
commit 8235c3595c
4 changed files with 7 additions and 9 deletions

View file

@ -39,6 +39,11 @@ def get_api_tokens_with_caller_flag(caller_token: str) -> list[TokenInfoWithIsCa
]
def is_token_valid(token) -> bool:
"""Check if token is valid"""
return TOKEN_REPO.is_token_valid(token)
class NotFoundException(Exception):
"""Not found exception"""

View file

@ -2,7 +2,7 @@ from fastapi import Depends, HTTPException, status
from fastapi.security import APIKeyHeader
from pydantic import BaseModel
from selfprivacy_api.utils.auth import is_token_valid
from selfprivacy_api.actions.api_tokens import is_token_valid
class TokenHeader(BaseModel):

View file

@ -4,7 +4,7 @@ import typing
from strawberry.permission import BasePermission
from strawberry.types import Info
from selfprivacy_api.utils.auth import is_token_valid
from selfprivacy_api.actions.api_tokens import is_token_valid
class IsAuthenticated(BasePermission):

View file

@ -66,13 +66,6 @@ def _validate_token_name(name):
return name
def is_token_valid(token):
"""Check if token is valid"""
if token in _get_tokens():
return True
return False
class BasicTokenInfo(BaseModel):
"""Token info"""