From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uCgDF3d5aGGnHgAAgWs5BA (envelope-from ) for ; Thu, 14 Oct 2021 20:39:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wFW5End5aGGCTQAA1q6Kng (envelope-from ) for ; Thu, 14 Oct 2021 18:39:51 +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 43F96E76E for ; Thu, 14 Oct 2021 20:39:50 +0200 (CEST) Received: from localhost ([::1]:38036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mb5dt-0004yS-0H for larch@yhetil.org; Thu, 14 Oct 2021 14:39:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mb5dX-0004yD-Gx for guix-devel@gnu.org; Thu, 14 Oct 2021 14:39:27 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:40459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mb5dV-0002Cf-74 for guix-devel@gnu.org; Thu, 14 Oct 2021 14:39:27 -0400 Received: by mail-wr1-x435.google.com with SMTP id i12so21976963wrb.7 for ; Thu, 14 Oct 2021 11:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=zfwf7wbsyE/mMl28yWRwJcAY0t4yBBjYr6mBibXblbI=; b=F80XGKNxMqaAmgVqEJKxM9Iye4bi14ZGuc2cZsiDJXzf6s251OtZ56TLKn6N2rmJO0 yGQJPkQwU55I2VhPxI7ZqR8YST5xDLUDh5rFi41reAow4/GtjxYD4roFt0eeNJs3FWOi gbXlV/byWh/Or6FqvM+w4VM4HXdczwildOJQ26wFsVHbUp6FkEbjkQiiz+cp6opOp0yQ qR1OO6/Sho5hBqln9lUN+Gmy4Dj88rNVHeAKvofRVhHwksj7BhnWU5kma/5o5xBLmpYn Y62z7aOJgTCWByk6Ek+c4H2l7YaueFX3cAxKHPZgsvLIEziXUHyESeoUrT8DWoRN1jSx 1u0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=zfwf7wbsyE/mMl28yWRwJcAY0t4yBBjYr6mBibXblbI=; b=Nf8/1wqNA2HAgm6nGxkjiFKp46dDEi7/cEi512/fP3lEBm3MXjX0la/HhDA/2Vf2zz SDDt0fb4iHYcCoxnZr/vkdiyzKSVDMtAlaPbNbUEIURqvXy5GXzlagSExXNC6mectuVI mhxKfNWyh75Y1zDBmwBrPBK9WA+ku6h/nZVMszaAaGfaHHiuAl2Q9rxZ01mJuCE2MDnP r4HIGcrty5KY7Ui6xcaTm559HqD43Csf7TLKj1GNt65q1h8t9NFqOp49YEPDCywS9R8r cWBxWe8r9fExOdpG0VjQ6/KKMfJpVeG6JkCrmkepJnJkcGsf7GuYcN3+egEwJ8BVOK+4 qMiw== X-Gm-Message-State: AOAM532QZwr/KbGowK24vcEcx2pMZeKnxWV/ocC88CgVMM7PMj7rwZtk OeeI7ZCTBgo+XE+bk7A9m6ktVRt8FCY= X-Google-Smtp-Source: ABdhPJxU7zXXGhOtay15gtRNL1lWVH/rd1CtHr2rDiaLA/zFpQxAjxopjmcTia+tgWVNvlVgZIMMnQ== X-Received: by 2002:a5d:62cc:: with SMTP id o12mr8826568wrv.324.1634236763225; Thu, 14 Oct 2021 11:39:23 -0700 (PDT) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id q7sm3101827wrs.73.2021.10.14.11.39.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 11:39:22 -0700 (PDT) From: zimoun To: Guix Devel Subject: issue with SWH ratelimit (authorization via HTTP header) Date: Thu, 14 Oct 2021 20:31:23 +0200 Message-ID: <86tuhjpif8.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1634236790; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=zfwf7wbsyE/mMl28yWRwJcAY0t4yBBjYr6mBibXblbI=; b=pnxiDcQZ4hRFpn0qwV/pvg+TT5t2Y5qRxcJ8vXkQ+zTa6hztaIUEpD7Dnh/v15Fqy07Ql+ tfqPzNAHIWagKaA4h4PXx6eiQ6263OXtr9nTxhfx3+0+CLv5zFb/sbQkjk64GUAwkoTrAU LMidA+cnJ4sNhzlTUO0WmPn7ydWp8WlC6ZV1zfm7EZPel4PyhBYzRJCMQtRzdJTaYfy+kb 3ZnFe5RXz8d1Fqhq/A9RRuo1hvMKTDAeUF1q2hAK42qPQxEDf8WbqNeQH2GUxrQ9fN3reS pHzmSXX5ARLZI7Nn+Dl98Rn0nJK4kPKcy1B8pqEcFTZnd0qNOA/1rbD5G04fHQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634236790; a=rsa-sha256; cv=none; b=WVzfQDs3bHeLa88ZGQz/vefMjKrIdaUK+bEKhjO2e4OhMCLB8kiLXP/66syHDBZMlZCda6 5F+ua+iXFMdJK6ZFRf8gehbllshBN3z59tS5fyTts7HGXJbdk/5K1m6cyKaSl4Ty1sSVeB ng7p0sotmtqJSbpjSyAZYCAG78ha893Juka/jiYoNp9isjhWRALvP5ki+oHD8I7LDDpcqa yizkHECKjwNoTu2IvTWJXTgSb6wx6Q7dwVCPOJDwGbl7Z6e5nAqC8rlJnJ6bXg7HVszRO1 hMwFPaUdtG5JwKLs2nuBrlSUzF5om3iMuOn3xV1xY6qs50ce2Apez9I9jxgiqg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=F80XGKNx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: -3.12 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=F80XGKNx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 43F96E76E X-Spam-Score: -3.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: orf7gXg+HB2Y Hi, I am puzzled by the module =E2=80=99(web client)=E2=80=99. SWH allows authorization via token which sets the ratelimit to 1200 instead of 120. But I fails to use it with Guile. Well, first thing first: --8<---------------cut here---------------start------------->8--- $ guix repl GNU Guile 3.0.7 Copyright (C) 1995-2021 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guix-user)> ,use(web client) scheme@(guix-user)> (http-request "https://archive.softwareheritage.org/api= /1/stat/counters/" #:method 'GET) $1 =3D #< version: (1 . 1) code: 200 reason-phrase: "OK" headers:= ((date . #) (server . "gunicorn/19.9.0") (content-type= application/json) (vary accept cookie accept-encoding) (allow GET OPTIONS = HEAD OPTIONS) (x-frame-options . "SAMEORIGIN") (via "1.1 archive.softwarehe= ritage.org") (x-varnish . "35616175 35955724") (age . 129) (via "1.1 varnis= h (Varnish/6.1)") (strict-transport-security . "max-age=3D15768000;") (acce= pt-ranges bytes) (content-length . 124) (connection close)) port: #> $2 =3D #vu8(123 34 111 114 105 103 105 110 34 58 49 54 54 49 55 49 49 54 50= 44 34 114 101 118 105 115 105 111 110 34 58 50 52 49 53 54 49 49 54 56 51 = 44 34 99 111 110 116 101 110 116 34 58 49 49 51 57 53 48 51 54 48 55 55 44 = 34 100 105 114 101 99 116 111 114 121 34 58 57 53 48 50 49 56 57 52 48 56 4= 4 34 114 101 108 101 97 115 101 34 58 50 49 50 48 53 52 48 51 44 34 112 101= 114 115 111 110 34 58 52 53 56 55 54 56 51 53 125) scheme@(guix-user)> (http-request "https://archive.softwareheritage.org/api= /1/stat/counters/" #:method 'POST) $3 =3D #< version: (1 . 1) code: 405 reason-phrase: "Method Not A= llowed" headers: ((date . #) (server . "gunicorn/19.9.0= ") (content-type application/json) (vary accept cookie) (allow GET OPTIONS = HEAD OPTIONS) (x-ratelimit-limit . "120") (x-ratelimit-remaining . "117") (= x-ratelimit-reset . "1634235776") (x-frame-options . "SAMEORIGIN") (content= -length . 72) (via "1.1 archive.softwareheritage.org") (x-varnish . "356162= 22") (age . 0) (via "1.1 varnish (Varnish/6.1)") (strict-transport-security= . "max-age=3D15768000;") (connection close)) port: #> $4 =3D #vu8(123 34 101 120 99 101 112 116 105 111 110 34 58 34 77 101 116 1= 04 111 100 78 111 116 65 108 108 111 119 101 100 34 44 34 114 101 97 115 11= 1 110 34 58 34 77 101 116 104 111 100 32 92 34 80 79 83 84 92 34 32 110 111= 116 32 97 108 108 111 119 101 100 46 34 125) --8<---------------cut here---------------end--------------->8--- Here, it works but as you can see, the X-RateLimit is at 120. Next step, define the token from SWH. And it fails. --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> (define token 'eyJhbGc=E2=80=A6) scheme@(guix-user)> (http-request "https://archive.softwareheritage.org/api= /1/stat/counters/" #:method 'GET #:headers `((authorization . (bearer ,toke= n)))) $5 =3D #< version: (1 . 1) code: 403 reason-phrase: "Forbidden" h= eaders: ((date . #) (server . "gunicorn/19.9.0") (conte= nt-type application/json) (vary accept cookie) (allow GET OPTIONS HEAD OPTI= ONS) (x-frame-options . "SAMEORIGIN") (content-length . 104) (via "1.1 arch= ive.softwareheritage.org") (x-varnish . "35741654") (age . 0) (via "1.1 var= nish (Varnish/6.1)") (strict-transport-security . "max-age=3D15768000;") (c= onnection close)) port: #> $6 =3D #vu8(123 34 101 120 99 101 112 116 105 111 110 34 58 34 65 117 116 1= 04 101 110 116 105 99 97 116 105 111 110 70 97 105 108 101 100 34 44 34 114= 101 97 115 111 110 34 58 34 73 110 118 97 108 105 100 32 111 114 32 117 11= 0 115 117 112 112 111 114 116 101 100 32 72 84 84 80 32 97 117 116 104 111 = 114 105 122 97 116 105 111 110 32 116 121 112 101 32 40 98 101 97 114 101 1= 14 41 46 34 125) scheme@(guix-user)> (http-request "https://archive.softwareheritage.org/api= /1/stat/counters/" #:method 'POST #:headers `((authorization . (bearer ,tok= en)))) $7 =3D #< version: (1 . 1) code: 403 reason-phrase: "Forbidden" h= eaders: ((date . #) (server . "gunicorn/19.9.0") (conte= nt-type application/json) (vary accept cookie) (allow GET OPTIONS HEAD OPTI= ONS) (x-frame-options . "SAMEORIGIN") (content-length . 104) (via "1.1 arch= ive.softwareheritage.org") (x-varnish . "36086556") (age . 0) (via "1.1 var= nish (Varnish/6.1)") (strict-transport-security . "max-age=3D15768000;") (c= onnection close)) port: #> $8 =3D #vu8(123 34 101 120 99 101 112 116 105 111 110 34 58 34 65 117 116 1= 04 101 110 116 105 99 97 116 105 111 110 70 97 105 108 101 100 34 44 34 114= 101 97 115 111 110 34 58 34 73 110 118 97 108 105 100 32 111 114 32 117 11= 0 115 117 112 112 111 114 116 101 100 32 72 84 84 80 32 97 117 116 104 111 = 114 105 122 97 116 105 111 110 32 116 121 112 101 32 40 98 101 97 114 101 1= 14 41 46 34 125) --8<---------------cut here---------------end--------------->8--- The most probable explanations is that the header is badly formed. How to do it? Because it works using =E2=80=99curl=E2=80=99. --8<---------------cut here---------------start------------->8--- $ curl -i https://archive.softwareheritage.org/api/1/stat/counters/ HTTP/1.1 200 OK Date: Thu, 14 Oct 2021 18:27:48 GMT Server: gunicorn/19.9.0 Content-Type: application/json Vary: Accept,Cookie,Accept-Encoding Allow: GET, OPTIONS, HEAD, OPTIONS X-RateLimit-Limit: 120 X-RateLimit-Remaining: 116 X-RateLimit-Reset: 1634236081 X-Frame-Options: SAMEORIGIN Via: 1.1 archive.softwareheritage.org X-Varnish: 35551144 Age: 0 Via: 1.1 varnish (Varnish/6.1) Strict-Transport-Security: max-age=3D15768000; Accept-Ranges: bytes Content-Length: 124 Connection: keep-alive {"origin":166171162,"revision":2415611683,"content":11395036077,"directory"= :9502189408,"release":21205686,"person":45876835} $ curl -i -H "Authorization: Bearer ${TOKEN}" https://archive.softwareheri= tage.org/api/1/stat/counters/ HTTP/1.1 200 OK Date: Thu, 14 Oct 2021 18:27:53 GMT Server: gunicorn/19.9.0 Content-Type: application/json Vary: Accept,Cookie,Accept-Encoding Allow: GET, OPTIONS, HEAD, OPTIONS X-RateLimit-Limit: 1200 X-RateLimit-Remaining: 1195 X-RateLimit-Reset: 1634236075 X-Frame-Options: SAMEORIGIN Content-Length: 124 Via: 1.1 archive.softwareheritage.org X-Varnish: 35897944 Age: 0 Via: 1.1 varnish (Varnish/6.1) Strict-Transport-Security: max-age=3D15768000; Accept-Ranges: bytes Connection: keep-alive {"origin":166171162,"revision":2415611683,"content":11395036077,"directory"= :9502189408,"release":21205686,"person":45876835} --8<---------------cut here---------------end--------------->8--- It would help for checking what is inside SWH. Thanks for any tips. All the best, simon