diff options
author | Mathieu Othacehe <othacehe@gnu.org> | 2021-10-18 14:33:09 +0000 |
---|---|---|
committer | Mathieu Othacehe <othacehe@gnu.org> | 2021-10-18 14:37:26 +0000 |
commit | e486b2b674badc80627b11077b7df2ac1cab92d8 (patch) | |
tree | 5909547a69c4b185b878c8f0fe8152f1c01fef04 /guix/swh.scm | |
parent | 0df1eb029efe5ebe3f02e36fa650cae4aaba89ec (diff) | |
parent | 88badc074a5dbebf80115918cf6c0009075154d2 (diff) | |
download | guix-patches-e486b2b674badc80627b11077b7df2ac1cab92d8.tar guix-patches-e486b2b674badc80627b11077b7df2ac1cab92d8.tar.gz |
Merge remote-tracking branch 'signed/master' into core-updates
Diffstat (limited to 'guix/swh.scm')
-rw-r--r-- | guix/swh.scm | 11 |
1 files changed, 11 insertions, 0 deletions
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 <ludo@gnu.org> ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> +;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -136,6 +137,12 @@ ;; 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 +;; <https://archive.softwareheritage.org/api/> +(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 @@ FALSE-IF-404? is true, return #f upon 404 responses." (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 <https://archive.softwareheritage.org/api/#rate-limiting>. |