Show More
@@ -493,8 +493,10 b' def opener(ui, authinfo=None):' | |||||
493 |
|
493 | |||
494 | passmgr = passwordmgr(ui, ui.httppasswordmgrdb) |
|
494 | passmgr = passwordmgr(ui, ui.httppasswordmgrdb) | |
495 | if authinfo is not None: |
|
495 | if authinfo is not None: | |
496 |
|
|
496 | realm, uris, user, passwd = authinfo | |
497 | user, passwd = authinfo[2:4] |
|
497 | saveduser, savedpass = passmgr.find_stored_password(uris[0]) | |
|
498 | if user != saveduser or passwd: | |||
|
499 | passmgr.add_password(realm, uris, user, passwd) | |||
498 | ui.debug('http auth: user %s, password %s\n' % |
|
500 | ui.debug('http auth: user %s, password %s\n' % | |
499 | (user, passwd and '*' * len(passwd) or 'not set')) |
|
501 | (user, passwd and '*' * len(passwd) or 'not set')) | |
500 |
|
502 |
@@ -380,4 +380,60 b' available locally.' | |||||
380 |
|
380 | |||
381 | $ killdaemons.py |
|
381 | $ killdaemons.py | |
382 |
|
382 | |||
|
383 | largefiles should not ask for password again after succesfull authorization | |||
|
384 | ||||
|
385 | $ hg init credentialmain | |||
|
386 | $ cd credentialmain | |||
|
387 | $ echo "aaa" >> a | |||
|
388 | $ hg add --large a | |||
|
389 | $ hg commit -m "a" | |||
|
390 | Invoking status precommit hook | |||
|
391 | A a | |||
|
392 | ||||
|
393 | Before running server clear the user cache to force clone to download | |||
|
394 | a large file from the server rather than to get it from the cache | |||
|
395 | ||||
|
396 | $ rm "${USERCACHE}"/* | |||
|
397 | ||||
|
398 | $ cd .. | |||
|
399 | $ cat << EOT > userpass.py | |||
|
400 | > import base64 | |||
|
401 | > from mercurial.hgweb import common | |||
|
402 | > def perform_authentication(hgweb, req, op): | |||
|
403 | > auth = req.env.get('HTTP_AUTHORIZATION') | |||
|
404 | > if not auth: | |||
|
405 | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', | |||
|
406 | > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) | |||
|
407 | > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: | |||
|
408 | > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') | |||
|
409 | > def extsetup(): | |||
|
410 | > common.permhooks.insert(0, perform_authentication) | |||
|
411 | > EOT | |||
|
412 | $ hg serve --config extensions.x=userpass.py -R credentialmain \ | |||
|
413 | > -d -p $HGPORT --pid-file hg.pid -A access.log | |||
|
414 | $ cat hg.pid >> $DAEMON_PIDS | |||
|
415 | $ cat << EOF > get_pass.py | |||
|
416 | > import getpass | |||
|
417 | > def newgetpass(arg): | |||
|
418 | > return "pass" | |||
|
419 | > getpass.getpass = newgetpass | |||
|
420 | > EOF | |||
|
421 | $ hg clone --config ui.interactive=true --config extensions.getpass=get_pass.py \ | |||
|
422 | > http://user@localhost:$HGPORT credentialclone | |||
|
423 | requesting all changes | |||
|
424 | http authorization required for http://localhost:$HGPORT/ | |||
|
425 | realm: mercurial | |||
|
426 | user: user | |||
|
427 | password: adding changesets | |||
|
428 | adding manifests | |||
|
429 | adding file changes | |||
|
430 | added 1 changesets with 1 changes to 1 files | |||
|
431 | updating to branch default | |||
|
432 | getting changed largefiles | |||
|
433 | 1 largefiles updated, 0 removed | |||
|
434 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
435 | ||||
|
436 | $ rm hg.pid access.log | |||
|
437 | $ killdaemons.py | |||
|
438 | ||||
383 | #endif |
|
439 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now