From: Kevin Stange <kevin@steadfast.net>
To: git@vger.kernel.org
Subject: [RFC] Deal with HTTP 401 by requesting credentials.
Date: Thu, 31 May 2012 17:24:55 -0500 [thread overview]
Message-ID: <4FC7EFB7.4090704@steadfast.net> (raw)
Request credentials from the user if none are already defined when a
HTTP 401 is received on a restricted repository. Then, resubmit the
request and return the final result.
This allows all webdav transactions to obtain credentials without having
to individually handle the case in each request. Having push working
with HTTP auth is needed for a use case I have where storing the
credentials in .netrc or using SSH keys is inappropriate.
Apologies for anything wrong I might have done here. I'm not used to
procedures for this sort of patch submission, or terribly familiar with
the code base. I'm seeking advice on whether this approach is sane or
completely crazy, and I'm willing to adjust it to make it suitable for
inclusion.
Signed-off-by: Kevin <kevin@steadfast.net>
---
http.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/http.c b/http.c
index 5cb87f1..e1c9e65 100644
--- a/http.c
+++ b/http.c
@@ -668,6 +668,21 @@ void finish_active_slot(struct active_request_slot
*slot)
closedown_active_slot(slot);
curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
+ if (slot->http_code == 401) {
+ if(!http_auth.username && !http_auth.password) {
+ active_requests++;
+ credential_fill(&http_auth);
+ init_curl_http_auth(slot->curl);
+ (*slot->finished) = 1;
+ if (start_active_slot(slot)) {
+ run_active_slot(slot);
+ return;
+ }
+ } else {
+ fprintf(stderr,"Authentication Failed!\n");
+ }
+ }
+
if (slot->finished != NULL)
(*slot->finished) = 1;
--
1.7.11.rc0.55.gb2478aa
--
Kevin Stange
Chief Technology Officer
Steadfast Networks
http://steadfast.net
Phone: 312-602-2689 ext. 203 | Fax: 312-602-2688 | Cell: 312-320-5867
next reply other threads:[~2012-05-31 22:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-31 22:24 Kevin Stange [this message]
2012-05-31 23:18 ` [RFC] Deal with HTTP 401 by requesting credentials Kevin Stange
2012-06-01 8:35 ` Jeff King
2012-06-01 17:01 ` Junio C Hamano
2012-06-05 16:23 ` Jeff King
2012-06-01 17:02 ` Kevin Stange
2012-06-05 16:28 ` Jeff King
2012-06-05 16:41 ` Kevin Stange
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FC7EFB7.4090704@steadfast.net \
--to=kevin@steadfast.net \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).