From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Atom X Zane Newsgroups: gmane.lisp.guile.bugs Subject: bug#14370: [PATCH] Write out HTTP Basic auth headers correctly Date: Wed, 8 May 2013 01:50:15 -0700 Message-ID: <87haidvlcd.fsf@atomx.deadlyhead.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1368028027 19408 80.91.229.3 (8 May 2013 15:47:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 May 2013 15:47:07 +0000 (UTC) To: 14370@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed May 08 17:47:07 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ua6aA-00033d-Fg for guile-bugs@m.gmane.org; Wed, 08 May 2013 17:47:06 +0200 Original-Received: from localhost ([::1]:54606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua6aA-0005sr-3t for guile-bugs@m.gmane.org; Wed, 08 May 2013 11:47:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua6a2-0005nF-9t for bug-guile@gnu.org; Wed, 08 May 2013 11:47:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ua6Zx-0002MC-Vb for bug-guile@gnu.org; Wed, 08 May 2013 11:46:58 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua6Zx-0002M7-MR for bug-guile@gnu.org; Wed, 08 May 2013 11:46:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Ua6b4-0006cz-66 for bug-guile@gnu.org; Wed, 08 May 2013 11:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Atom X Zane Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 08 May 2013 15:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14370 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136802803325337 (code B ref -1); Wed, 08 May 2013 15:48:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 May 2013 15:47:13 +0000 Original-Received: from localhost ([127.0.0.1]:34006 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ua6aG-0006ab-EX for submit@debbugs.gnu.org; Wed, 08 May 2013 11:47:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47475) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ua1G1-0002OK-F7 for submit@debbugs.gnu.org; Wed, 08 May 2013 06:06:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ua1Es-00040V-1S for submit@debbugs.gnu.org; Wed, 08 May 2013 06:04:49 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:48472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua1Er-00040R-Uf for submit@debbugs.gnu.org; Wed, 08 May 2013 06:04:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua1Eo-0003Cy-0J for bug-guile@gnu.org; Wed, 08 May 2013 06:04:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ua1Eh-0003z3-Ug for bug-guile@gnu.org; Wed, 08 May 2013 06:04:41 -0400 Original-Received: from caibbdcaaaaf.dreamhost.com ([208.113.200.5]:45481 helo=homiemail-a93.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua1Eh-0003yt-Ok for bug-guile@gnu.org; Wed, 08 May 2013 06:04:35 -0400 Original-Received: from homiemail-a93.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a93.g.dreamhost.com (Postfix) with ESMTP id 5286484065 for ; Wed, 8 May 2013 03:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=deadlyhead.com; h=from:to :subject:date:message-id:mime-version:content-type; s= deadlyhead.com; bh=2AMQs6IpO39zKxUg1KqoajEO3OE=; b=YWtMxzIfgb7QO 4lcDlt52C2MFBVQ271BG2t5RBRlNwWLfVC7jK/yAxsAElIcZXn+A1n0TTBr7fD/X HmU0/1QhRSbyhTPPAprmyCl98MXBLe0mEKV6PFShM1kB1qIx/QIYVH21Afci6Rur H0UZ2PPaZXsFzmQmEM5/PLPn0Vay0w= Original-Received: from atomx.deadlyhead.home.deadlyhead.com (cpe-172-250-30-16.socal.res.rr.com [172.250.30.16]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: atom@deadlyhead.com) by homiemail-a93.g.dreamhost.com (Postfix) with ESMTPSA id 338A38405C for ; Wed, 8 May 2013 03:04:35 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Wed, 08 May 2013 11:47:10 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7122 Archived-At: HTTP Basic authorization headers are not output correctly, leaving off the user credentials in the Authorization: header. Test case: (let ((req (build-request (build-uri 'http #:host "example.com") #:headers '((authorization basic . "dXNlcm5hbWU6cGFzc3dvcmQ=") )))) (write-request req (current-output-port))) Expected output: > GET / HTTP/1.1 > Host: example.com > Authorization: basic dXNlcm5hbWU6cGFzc3dvcmQ= Actual output: > GET / HTTP/1.1 > Host: example.com > Authorization: basic As you can see, the user credentials aren't actually written out, causing the server to return a "401 Authorization required" response. I have included a patch which remedies this problem. -- Atom X Zane * module/web/http.scm: modify write-credentials to display the base64-encoded concatenation of username and password if the authorization model is 'basic --- module/web/http.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/web/http.scm b/module/web/http.scm index 35169ef..0e5db5d 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -913,10 +913,10 @@ as an ordered alist." (define (write-credentials val port) (display (car val) port) + (display #\space port) (if (pair? (cdr val)) - (begin - (display #\space port) - (write-key-value-list (cdr val) port)))) + (write-key-value-list (cdr val) port) + (display (cdr val) port))) ;; challenges = 1#challenge ;; challenge = auth-scheme 1*SP 1#auth-param -- 1.7.10.4