unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: zimoun <zimon.toutoune@gmail.com>
Cc: 51216@debbugs.gnu.org
Subject: [bug#51216] [PATCH 0/1] swh: Allows token from Software Heritage authentication service.
Date: Thu, 14 Oct 2021 23:46:46 +0200	[thread overview]
Message-ID: <87o87rl1o9.fsf_-_@gnu.org> (raw)
In-Reply-To: <20211014213346.3270670-1-zimon.toutoune@gmail.com> (zimoun's message of "Thu, 14 Oct 2021 23:33:46 +0200")

zimoun <zimon.toutoune@gmail.com> skribis:

> The token is provided using the environment variable GUIX_SWH_TOKEN.
>
> * guix/swh.scm (swh-token): New variable.
> (http-get*, http-post*): Use it.

[...]

> +;; Token from an account to the Software Heritage Authentication service
> +;; <https://archive.softwareheritage.org/api/>
> +(define swh-token
> +  (match (getenv "GUIX_SWH_TOKEN")
> +    (#f #f)
> +    ((? string-null? s) #f)
> +    ((? string? s) (string->symbol s))))

Could you turn it into a SRFI-39 parameter?

>  ;; XXX: Work around a bug in Guile 3.0.2 where #:verify-certificate? would
>  ;; be ignored (<https://bugs.gnu.org/40486>).
>  (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))

These two procedures are meant to go away as soon as Guile > 3.0.2 is
required.

Could you instead pass #:headers in the ‘call’ procedure, and maybe in
‘vault-fetch’ too?

Thanks!

Ludo’.




  reply	other threads:[~2021-10-14 21:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 21:32 [bug#51216] [PATCH 0/1] swh: Allows token from Software Heritage authentication service zimoun
2021-10-14 21:33 ` [bug#51216] [PATCH 1/1] " zimoun
2021-10-14 21:46   ` Ludovic Courtès [this message]
2021-10-14 21:44 ` [bug#51216] [PATCH 0/1] " Ludovic Courtès
2021-10-14 21:52   ` zimoun
2021-10-14 22:14 ` [bug#51216] [PATCH v2] " zimoun
2021-10-15 20:54   ` bug#51216: [PATCH 0/1] " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o87rl1o9.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=51216@debbugs.gnu.org \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).