Show More
@@ -0,0 +1,52 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | """ | |||
|
4 | Storing HTTP authentication passwords in keyring database. | |||
|
5 | ||||
|
6 | Installation method(s): | |||
|
7 | ||||
|
8 | 1) in ~/.hgrc (or /etc/hgext/...) | |||
|
9 | ||||
|
10 | [extensions] | |||
|
11 | ... | |||
|
12 | hgext.mercurial_keyring = /path/to/mercurial_keyring.py | |||
|
13 | ||||
|
14 | """ | |||
|
15 | ||||
|
16 | from mercurial import hg, repo, util | |||
|
17 | from mercurial.i18n import _ | |||
|
18 | try: | |||
|
19 | from mercurial.url import passwordmgr | |||
|
20 | except: | |||
|
21 | from mercurial.httprepo import passwordmgr | |||
|
22 | ||||
|
23 | import keyring | |||
|
24 | import getpass | |||
|
25 | from urlparse import urlparse | |||
|
26 | ||||
|
27 | KEYRING_ENTRY_PFX = "Mercurial:%s" | |||
|
28 | ||||
|
29 | def monkeypatch_method(cls): | |||
|
30 | def decorator(func): | |||
|
31 | setattr(cls, func.__name__, func) | |||
|
32 | return func | |||
|
33 | return decorator | |||
|
34 | ||||
|
35 | @monkeypatch_method(passwordmgr) | |||
|
36 | def find_user_password(self, realm, authuri): | |||
|
37 | """ | |||
|
38 | keyring-based implementation of username/password query | |||
|
39 | ||||
|
40 | Passwords are saved in gnome keyring, OSX/Chain or other platform | |||
|
41 | specific storage and keyed by the repository url | |||
|
42 | """ | |||
|
43 | # Calculate the true url. authuri happens to contain things like | |||
|
44 | # https://repo.machine.com/repos/apps/module?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between | |||
|
45 | parsed_url = urlparse(authuri) | |||
|
46 | base_url = "%s://%s%s" % (parsed_url.scheme, parsed_url.netloc, parsed_url.path) | |||
|
47 | ||||
|
48 | print "find_user_password", realm, base_url | |||
|
49 | ||||
|
50 | # return user, password | |||
|
51 | return None, None | |||
|
52 |
General Comments 0
You need to be logged in to leave comments.
Login now