Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer
2024-08-20 19:35:43 +02:00
parent b48d5892a8
commit e4c54c2d1f
2 changed files with 3 additions and 5 deletions

View File

@ -40,7 +40,7 @@ def auth_user_lookup(raw_header: bytes) -> User | None:
if user:
CTX_AUTH_VIA.set("secret_key")
return user
raise AuthenticationFailed("Token invalid/expired")
return None
def token_secret_key(value: str) -> User | None:

View File

@ -2,12 +2,11 @@
from django.conf import settings
from django.test import TestCase
from rest_framework.exceptions import AuthenticationFailed
from authentik.api.authentication import bearer_auth
from authentik.blueprints.tests import reconcile_app
from authentik.core.models import User, UserTypes
from authentik.outposts.apps import MANAGED_OUTPOST
from authentik.outposts.authentication import bearer_auth
from authentik.outposts.models import Outpost
@ -20,8 +19,7 @@ class TestAPIAuth(TestCase):
outpost = Outpost.objects.filter(managed=MANAGED_OUTPOST).first()
outpost.user.delete()
outpost.delete()
with self.assertRaises(AuthenticationFailed):
bearer_auth(f"Bearer {settings.SECRET_KEY}".encode())
self.assertIsNone(bearer_auth(f"Bearer {settings.SECRET_KEY}".encode()))
@reconcile_app("authentik_outposts")
def test_managed_outpost_success(self):