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 2EFWHE6iaGG4cQAAgWs5BA (envelope-from ) for ; Thu, 14 Oct 2021 23:34:06 +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 BU8dGE6iaGGGQgAA1q6Kng (envelope-from ) for ; Thu, 14 Oct 2021 21:34:06 +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 206CB8DEF for ; Thu, 14 Oct 2021 23:34:06 +0200 (CEST) Received: from localhost ([::1]:51098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mb8MX-0006tQ-A0 for larch@yhetil.org; Thu, 14 Oct 2021 17:34:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mb8MU-0006tH-07 for guix-patches@gnu.org; Thu, 14 Oct 2021 17:34:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mb8MT-0001rx-O6 for guix-patches@gnu.org; Thu, 14 Oct 2021 17:34:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mb8MT-0004lT-La for guix-patches@gnu.org; Thu, 14 Oct 2021 17:34:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51216] [PATCH 1/1] 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 21:34:01 +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.163424723718290 (code B ref 51216); Thu, 14 Oct 2021 21:34:01 +0000 Received: (at 51216) by debbugs.gnu.org; 14 Oct 2021 21:33:57 +0000 Received: from localhost ([127.0.0.1]:37233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mb8MP-0004kt-8i for submit@debbugs.gnu.org; Thu, 14 Oct 2021 17:33:57 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:37696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mb8MM-0004kB-IA for 51216@debbugs.gnu.org; Thu, 14 Oct 2021 17:33:55 -0400 Received: by mail-wr1-f47.google.com with SMTP id e12so22760111wra.4 for <51216@debbugs.gnu.org>; Thu, 14 Oct 2021 14:33:54 -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=da1LKgqJdQZT5gfIhnwBtSEI9OUgIxaMI4gcrTXMa+g=; b=eTHrukkLq0ru3Fkhzje8FodFT8QzoraM0394eiaUtx/Q9vgg0JNlExQQ2YC9c6pAMc vptjnyHSxFbAihQMO1OKoHFgn6rAjPd58uFV+NRZSipOtHdSbeHpPykdKA9Fe+fm6u80 FtCak5Rq6T/hvykQkuauohadahx4fRZbkQK2jSb1W+hn5trr3Mj+5gJk4KK6N2WimsHq Z0MJNv2B3398o4cSOWsPq+4atiqXrHKQsOdcSIAWLPJ24r71D86Ka/MKAaOXVUTGltS5 AVa3ABKDZk7vb/KVyoTX43HeEmSW2lwW75RT5wpjIFgc3uoQutvPF2LrB2efjmXyGXDg 75tQ== 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=da1LKgqJdQZT5gfIhnwBtSEI9OUgIxaMI4gcrTXMa+g=; b=hF1K4jJMLLh9fqsuFYQQFQmqrKLf3+myrDmPCaZQ+a4NO6xnUq8YzsoNCTqwKahpy2 sBLOWqrCCZMjGfFr5LzZVddi9Z9h/AiLVitc7qpZCIKtBJQqC+NEym9kcOdAdXbRxFbk 4wUQezllbBI4q+onI8HSVFbBY+wMeehMOSiVt5uHjtTqxB9Qknk2mm4MnN7Qfi0G1BfD Fg+mib5EAalRZSnLTKhmwnHIadtkWb/K3ooMbKv8kj2upZDA32nUCfcecSS5wQ4UIO95 B2pJdYfQV0LqGz9+k4lUdRemHS9isVM+1jGJsUcVeAJHc7ATPj61LBePFn+PikyQ7WDv hUcQ== X-Gm-Message-State: AOAM531/2XU5Tf6/CqRLrG4jCWesxAw1i1d9nGwHhcpLtRRJK9PSVqwY Zw8YRwsp9/EXaaf51qRR/JTE6Yd2o3I= X-Google-Smtp-Source: ABdhPJxvF69zod7dXl1qThBdpuFzItq6d33s1u6zPpw5bb7KFOgjjxHv5hvL6XjfWDiaOXSaOIVTEg== X-Received: by 2002:adf:e584:: with SMTP id l4mr9414890wrm.173.1634247228510; Thu, 14 Oct 2021 14:33:48 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.117]) by smtp.gmail.com with ESMTPSA id k27sm3205993wms.21.2021.10.14.14.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 14:33:48 -0700 (PDT) From: zimoun Date: Thu, 14 Oct 2021 23:33:46 +0200 Message-Id: <20211014213346.3270670-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=1634247246; 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=da1LKgqJdQZT5gfIhnwBtSEI9OUgIxaMI4gcrTXMa+g=; b=kpNuMlCiO1DqmpOOGvSmRUOZeCG0OTNPAJP5acAP6yoQW/CZ5A+2zCpp3Bse42ayVeX6Mo najezlmYjsaQPwVmIJTj67ZDEQPYWDSXIEqeYsqRFmhY3Bs2+3SpwOSn5jwC8VT4VglwT4 W1boqNVnnJGnUxCOEBV0PEhMQojkrOBeS01V7uwlVlV2HZe+wUgT5Zw3SJMDii79Zt8h0m JBnOw7iMI1QFPBG8bMDJSAfrXh0R8ylRCySCO7f7kbRAbkfaMtBmdtiRYKF04VRflG191W MQyGuu3GH4zHQgfYqTSxlgR4fbNUaGCuSroe+9mw3lAzybPsboPpoRzbryXtXg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634247246; a=rsa-sha256; cv=none; b=iphsGZ+qR8od4BAaRlVq2SI+6D5CMv9VUl/X1Swrqr7QqJ23wG6u7D5XKXNfrmzvUsD+ZB UsSfLSVmfJpMBN9CULVVLwTSBAQqFA258VZ96Lm0ZDMc0k+3nnSdw+D30mNNGBPKU2RBug bV8BueXIV4YBMTc1qg2ts8kWdAvXA1KRmLttF9DvsMxSs8syGvnfoYSArow+KIOY5uJ8kR JLOz10JFccTr7uhyM9U6VEiWtWaVO+X17Bp0wgwsyvBLrF5UvRIryCG1kaGvdkYvGbfGgt lTM3kPGWgGvmDGIGcxzf1/wkBM/YHFReGvW4OEzsqHokSvIeBR2wqD50+6LE0Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=eTHrukkL; 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=eTHrukkL; 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: 206CB8DEF X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: RuUP1cWqXo4c The token is provided using the environment variable GUIX_SWH_TOKEN. * guix/swh.scm (swh-token): New variable. (http-get*, http-post*): Use it. --- guix/swh.scm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/guix/swh.scm b/guix/swh.scm index 5c41685a24..38a4af723a 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. ;;; @@ -153,12 +154,30 @@ (define url url (string-append url "/"))) +;; Token from an account to the Software Heritage Authentication service +;; +(define swh-token + (match (getenv "GUIX_SWH_TOKEN") + (#f #f) + ((? string-null? s) #f) + ((? string? s) (string->symbol s)))) + ;; XXX: Work around a bug in Guile 3.0.2 where #:verify-certificate? would ;; be ignored (). (define* (http-get* uri #:rest rest) - (apply http-request uri #:method 'GET rest)) + (apply http-request uri #:method 'GET + #:headers + (if swh-token + `((authorization . (Bearer ,swh-token))) + '()) + rest)) (define* (http-post* uri #:rest rest) - (apply http-request uri #:method 'POST rest)) + (apply http-request uri #:method 'POST + #:headers + (if swh-token + `((authorization . (Bearer ,swh-token))) + '()) + rest)) (define %date-regexp ;; Match strings like "2014-11-17T22:09:38+01:00" or -- 2.32.0