From patchwork Thu Oct 14 22:14:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 33852 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4F62A27BBE3; Thu, 14 Oct 2021 23:16:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 139B627BBE1 for ; Thu, 14 Oct 2021 23:16:13 +0100 (BST) Received: from localhost ([::1]:41688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mb91I-0005LN-3H for patchwork@mira.cbaines.net; Thu, 14 Oct 2021 18:16:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mb918-0005IT-L6 for guix-patches@gnu.org; Thu, 14 Oct 2021 18:16:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mb918-0007mN-CR for guix-patches@gnu.org; Thu, 14 Oct 2021 18:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mb918-0008VA-67 for guix-patches@gnu.org; Thu, 14 Oct 2021 18:16:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51216] [PATCH v2] swh: Allows token from Software Heritage authentication service. References: <20211014213238.3270613-1-zimon.toutoune@gmail.com> In-Reply-To: <20211014213238.3270613-1-zimon.toutoune@gmail.com> Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 14 Oct 2021 22:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51216 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51216@debbugs.gnu.org Cc: zimoun Received: via spool by 51216-submit@debbugs.gnu.org id=B51216.163424971232428 (code B ref 51216); Thu, 14 Oct 2021 22:16:02 +0000 Received: (at 51216) by debbugs.gnu.org; 14 Oct 2021 22:15:12 +0000 Received: from localhost ([127.0.0.1]:37268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mb90J-0008Qr-Qt for submit@debbugs.gnu.org; Thu, 14 Oct 2021 18:15:12 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:34769) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mb90F-0008Q2-KT for 51216@debbugs.gnu.org; Thu, 14 Oct 2021 18:15:10 -0400 Received: by mail-wr1-f52.google.com with SMTP id y3so23009939wrl.1 for <51216@debbugs.gnu.org>; Thu, 14 Oct 2021 15:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DNd7d1Zeu53U5BNTtNDasfbdoU1Fhq3QiHHegBeYL/Q=; b=c+/9bQhlkmVa2Gj1tfbrGt99t29K5mn6tRnZSrwZwdoSbCT9ADWDb0rbbfyav2Q9LW 3LYZybEyAvQb8vlOiWPD3Z7bxaH1FxU/TRlqFvaMrrYCkafzDJ32QniUbINjNlOBPP/s 7M9H8TJ7jKnBWKIzEYb4E7zk488kC8IsVQEcYHMAPBo4HVVrgnAoOazjg+0bpXj8KAyL TFZglMZ710RQoJCMBR7Gex7bt+pt2FzfuqNF1rw5jV0McF+wjfHaFSyNUxRLxgCXW3Vu IVLnPaQ5LySVHSsuy90fhYckuz9cd2tv+0KzYlPBoBTPZaQvJr+EqkgeWTEFrpgQD3ff 2SHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DNd7d1Zeu53U5BNTtNDasfbdoU1Fhq3QiHHegBeYL/Q=; b=BMS+S87hFIMZbJMTlYZbN9eGnsoJ9X6pz2e7/hqirBH+02rJbhfRQtP5WoG55ooWGL U9fgIIjumwxOiTqTNoC2EBME0jCAveKBX0+CilfJ6wXe4GdSbyudFHp6HFJ9Ko9d8Uc5 yEWsVv5c1rtg/1zvCMyK0WH854GMajjAvI8rqYhsxqc8YYYM/tnJubmjfJwQgBAVxXRf wo9VytbjRJojRzERgICEPbOjokfttg2AQUZ6G2p6V3NRYloUmBWoDNtE2ZCn3/OXF+z6 2UXAJjFmiYI4ZontB6pTqbw3OaprU3njdk1B4ykbzqeuqyfVdCccxW5xVrujs0uttBQI /KRw== X-Gm-Message-State: AOAM532+mdKTVJ/Wg/5pX+3BS1dzJ8EbH8HNyP13MQkt5IAr5TvuBGbQ L9+vU2jBfjy3NKgMNybr9BPtKPxYH2M= X-Google-Smtp-Source: ABdhPJxtQZeG8+DOkXDmpvIP4MazadDN1cQw4ArgeYcNJjeuPysuQ1aWk3E/FSA9guk0bNL0eLSDAg== X-Received: by 2002:a5d:4b43:: with SMTP id w3mr10248733wrs.404.1634249701839; Thu, 14 Oct 2021 15:15:01 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.117]) by smtp.gmail.com with ESMTPSA id z5sm11542694wmp.26.2021.10.14.15.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 15:15:01 -0700 (PDT) From: zimoun Date: Fri, 15 Oct 2021 00:14:54 +0200 Message-Id: <20211014221454.3272836-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches The token is provided using the environment variable GUIX_SWH_TOKEN. * guix/swh.scm (%swh-token): New variable. (call): Use it. --- guix/swh.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) base-commit: cf25ba2d773435af7af2cd315185acb16dcc6b58 diff --git a/guix/swh.scm b/guix/swh.scm index 5c41685a24..c7c1c873a2 100644 --- a/guix/swh.scm +++ b/guix/swh.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2020 Jakub Kądziołka ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -136,6 +137,12 @@ (define %verify-swh-certificate? ;; Whether to verify the X.509 HTTPS certificate for %SWH-BASE-URL. (make-parameter #t)) +;; Token from an account to the Software Heritage Authentication service +;; +(define %swh-token + (make-parameter (and=> (getenv "GUIX_SWH_TOKEN") + string->symbol))) + (define (swh-url path . rest) ;; URLs returned by the API may be relative or absolute. This has changed ;; without notice before. Handle both cases by detecting whether the path @@ -246,6 +253,10 @@ (define* (call url decode #:optional (method http-get*) (and ((%allow-request?) url method) (let*-values (((response port) (method url #:streaming? #t + #:headers + (if (%swh-token) + `((authorization . (Bearer ,(%swh-token)))) + '()) #:verify-certificate? (%verify-swh-certificate?)))) ;; See .