From nobody Fri Apr 19 04:35:40 2024 Delivered-To: importer@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=1645811004; cv=none; d=zohomail.com; s=zohoarc; b=hzL+CR8B2lBaNpgnjv531MeH4UzOvlUk424SO7CRZxYVU8m+LLLdbto81ym/0IuWWPpQI95DqeYxV/BXiKyf6UmKK5szO9E+XOlxFVfZBOsg0teSwa0jA+BZK99E+sUTuTDx+/Wu6Fmu8g3pI38z73MB21Ij6Ukca+DwUmPT1UM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645811004; 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=fnwC1NgbRu+BKts+3JNbR3HlZBaiHHwjFSeaM3QDj5vWNbKTYXw8VpFtiHnVQF9+AJfmEn4xstKsDmrEV6ujeiwrZ9gLgOxTi6sYy24LUjr0sB416gokbkhWqBulI4ZN8IhdoRWUbfzsC9bHi0lwmmH7oMNLI5MauIQRBMD+PL0= 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 1645811004514839.690446188857; Fri, 25 Feb 2022 09:43:24 -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=1645811003; 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=CJ0d8bn8quT0ob1GorONWDuk46qJNDkaNneDBPU436hdTko7/gBQBtCB2wDZ2NpOP/u/4C 8dHzMb7EHlad/UxojheRjPK6MRtBQ4sIX3dQKWXx3cxZwxa4B4hGnZv9x7h8AAQIn4WZzp sr4OCWVB9O+WPsnv03IGKhgX+x0NF5c= 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: 1645811005622100003 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