From nobody Thu Apr 25 14:54:52 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1645811002; cv=none; d=zohomail.com; s=zohoarc; b=aL4JOk/mdDcpTnD7MQpuaMB4MwUtz2h0WxkqRJap8hrExpK1UobXzMV7m3N7sIWaDTZaT7hG8xR2OKzpZgp2g9/KlLZwwHuD090+CrkMtCb9knIlzh+PElLZYXq/IYygRl4wfApU2rvRyLiqrX1rfmPmTKXByPmmmFV5Sj9Xc94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645811002; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Gz9rs3vOUSxXUjpkxk3w0OU+Hv+41lMQEocOeO4g718=; b=B1XzK2qZoQC3WqicF7C+B+2DXTUL5VaW6xJKENKpOhG/sBAn0KrnPfPWQbTjqwiW0oG+oT2IoBiEjQJDl3QU3KwY00Ofea6ElQjWPY6sT9lcRrKZE9nkCstJ1HHZOWaxKwEcEHYDJ1Q20Xc0t7g7toHI2S6l+Hn1AbM3h+wzrZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645811002470738.7637681818976; Fri, 25 Feb 2022 09:43:22 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-265-NyMa7TX1NKSgPuWHEoGwFA-1; Fri, 25 Feb 2022 12:43:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 031D21091DA4; Fri, 25 Feb 2022 17:43:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF4508C75C; Fri, 25 Feb 2022 17:43:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E6F771809C98; Fri, 25 Feb 2022 17:43:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21PHhHPv002333 for ; Fri, 25 Feb 2022 12:43:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id E9EB18AC2A; Fri, 25 Feb 2022 17:43:17 +0000 (UTC) Received: from avogadro.lan (unknown [10.39.193.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BEB78C75C for ; Fri, 25 Feb 2022 17:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645811001; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Gz9rs3vOUSxXUjpkxk3w0OU+Hv+41lMQEocOeO4g718=; b=DnpTiYkSE5gsEsa0mO+EHIsWneq51fNGL3npEMTmKrIOEVeyfR0BhbxzSf+7xpdBOHnd4s jlpp4CBbjY3v8iVa1PuMHvqqE7Ky2Gr7jjOS2ohzA1Rb798chV0E6Tj4fVqdRTy9ozuVJ2 sul9T7nfkp5DbbAw9TfCfyW1S4jvwm8= X-MC-Unique: NyMa7TX1NKSgPuWHEoGwFA-1 From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 25 Feb 2022 18:43:16 +0100 Message-Id: <20220225174316.612979-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] rest: re-enable CSRF X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645811004786100001 Content-Type: text/plain; charset="utf-8" Now that the REST API is used throughout patchew-cli, and we have switched to token authentication, avoid the possibility of forging cross-site requests. --- patchew/__init__.py | 7 ------- patchew/settings.py | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/patchew/__init__.py b/patchew/__init__.py index a592854..e69de29 100644 --- a/patchew/__init__.py +++ b/patchew/__init__.py @@ -1,7 +0,0 @@ -from rest_framework.authentication import SessionAuthentication - - -class CsrfExemptSessionAuthentication(SessionAuthentication): - def enforce_csrf(self, request): - # Skip CSRF until patchew-cli can switch to token-based authentica= tion - return diff --git a/patchew/settings.py b/patchew/settings.py index 189b9f7..8b19d19 100644 --- a/patchew/settings.py +++ b/patchew/settings.py @@ -68,7 +68,7 @@ MIDDLEWARE =3D [ REST_FRAMEWORK =3D { "DEFAULT_AUTHENTICATION_CLASSES": ( "rest_framework.authentication.TokenAuthentication", - "patchew.CsrfExemptSessionAuthentication", + "rest_framework.authentication.SessionAuthentication", ), "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagi= nation", "URL_FIELD_NAME": "resource_uri", --=20 2.34.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel