From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WD5QCiqsaGHlhAAAgWs5BA (envelope-from ) for ; Fri, 15 Oct 2021 00:16:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gJz2BSqsaGG/VQAA1q6Kng (envelope-from ) for ; Thu, 14 Oct 2021 22:16:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 967CE99C3 for ; Fri, 15 Oct 2021 00:16:09 +0200 (CEST) Received: from localhost ([::1]:41688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mb91E-0005LN-Hl for larch@yhetil.org; Thu, 14 Oct 2021 18:16:08 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1634249769; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DNd7d1Zeu53U5BNTtNDasfbdoU1Fhq3QiHHegBeYL/Q=; b=DbBCd9HNSbViG31BBQlDB7MXgUZHqH3IWFvpDcyyGlSR3lTy/YFE8dxXuew8nVjf24J8L7 CfWS5LhA9B7umgy4CY+y2cEjt39L1bjmBTi40POQ0K9/4U8vBijZos6wiAgvw6PNOy8HVd hsOx5S6BcgQpFd/J8tgsiOaeH3TtzetjXTudIYp4ckYvqBWkhRorFrBdWLfaResaL9eUTi Fye3FEAPbm8K3ORTAgPfWWZpZ/5Mf1aCqM8YdRSn8f0MJV4jD3z50W4dLg4WnWfx/SEg7y WVQvmJpH2TqgZyR3yBDuRwPDNItGdtGe+Yc8Mgney+J1Wai2NiU37i1oqLl3/A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634249769; a=rsa-sha256; cv=none; b=UltrToOuxmRhgSJSSw9rZitD0pNq8OYwq5XSLM9euI0P0knabmC4u+PewpQ+A7XX0sNZTc 6jwKr96JyHqrTUoecK0kqWDEqIawztjqhG5CIo7Qs9H6ByFVH64h42AyWCX+MIuh3u///d TaVD4K9KkmdNn/GsVORsJhssYKUGjGGD1FxWBVBG1TPQdpL5cjjXRuUPBMLS3eFIe+JTR+ o41hj37XDXa5d5J2vDQ4lK/KZ3tJRlW3ow3n7xGeZmEaDittS+qWJr8rom7QrjjWiKUCpK 3oi/r9wvvQNSboP3y3dum+whyuanUyRJf7+0YYs25A2Iof4J9QTV8H9knsYvoQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="c+/9bQhl"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="c+/9bQhl"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 967CE99C3 X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: Jwepfn/wwTfj 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(+) 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 . base-commit: cf25ba2d773435af7af2cd315185acb16dcc6b58 -- 2.32.0