diff --git a/ninja_jwt/authentication.py b/ninja_jwt/authentication.py index 8f2cd02c7..b2b637663 100644 --- a/ninja_jwt/authentication.py +++ b/ninja_jwt/authentication.py @@ -137,3 +137,11 @@ class AsyncJWTTokenUserAuth( ): async def authenticate(self, request: HttpRequest, token: str) -> Any: return await self.async_jwt_authenticate(request, token) + + +class SuperUserAuth(JWTAuth): + def get_user(self, validated_token): + user = super().get_user(validated_token) + if not user.is_superuser: + raise AuthenticationFailed("User must be superuser") + return user