from django.contrib.auth.middleware import RemoteUserMiddleware


class FETHeaderMiddleware(RemoteUserMiddleware):
    header = "Remote-User"

    def process_request(self, request):
        request.META[self.header] = request.META.get(
            self.header, request.headers.get(self.header, None)
        )

        super().process_request(request)

        if request.user.is_authenticated:
            request.user.is_admin = True
            request.user.is_superuser = True
            request.user.is_staff = True
