Show More
@@ -1,206 +1,222 b'' | |||
|
1 | .. -*- mode: rst -*- | |
|
1 | .. -*- mode: rst; compile-command: "rst2html README.txt README.html" -*- | |
|
2 | 2 | |
|
3 | 3 | ================= |
|
4 | 4 | mercurial_keyring |
|
5 | 5 | ================= |
|
6 | 6 | |
|
7 | 7 | ``mercurial_keyring`` is a Mercurial_ extension used to securely save |
|
8 | 8 | HTTP and SMTP authentication passwords in password databases (Gnome |
|
9 | 9 | Keyring, KDE KWallet, OSXKeyChain, specific solutions for Win32 and |
|
10 | 10 | command line). This extension uses and wraps services of the keyring_ |
|
11 | 11 | library. |
|
12 | 12 | |
|
13 | 13 | .. _keyring: http://pypi.python.org/pypi/keyring |
|
14 | 14 | .. _Mercurial: http://mercurial.selenic.com |
|
15 | 15 | |
|
16 | 16 | How does it work |
|
17 | 17 | ================ |
|
18 | 18 | |
|
19 | 19 | The extension prompts for the password on the first pull/push (in case |
|
20 | 20 | of HTTP) or first email (in case of SMTP), just like it is done by |
|
21 |
default, but saves the password. On successive |
|
|
22 | username in ``.hg/hgrc``, then for suitable password in the password | |
|
23 | database, and uses those credentials (if found). | |
|
21 | default, but saves the password in password database. On successive | |
|
22 | runs, whenever the password is needed, it checks for the username in | |
|
23 | ``.hg/hgrc``, then for suitable password in the password database, and | |
|
24 | uses those credentials (if found). | |
|
24 | 25 | |
|
25 | 26 | In case password turns out to be incorrect (either because it was |
|
26 | invalid, or because it was changed on the server) or missing it just | |
|
27 | invalid, or because it was changed on the server) or missing, it just | |
|
27 | 28 | prompts the user again. |
|
28 | 29 | |
|
29 | 30 | Passwords are identified by the combination of username and remote |
|
30 | 31 | address, so they can be reused between repositories if they access the |
|
31 | 32 | same remote repository (or the same SMTP server). |
|
32 | 33 | |
|
33 | 34 | Installation |
|
34 | 35 | ============ |
|
35 | 36 | |
|
36 | 37 | Prerequisites |
|
37 | 38 | ------------- |
|
38 | 39 | |
|
39 | Install the keyring_ library: | |
|
40 | This extension requires keyring_ and `mercurial_extension_utils`_ to | |
|
41 | work. In many cases both will be installed automatically while you | |
|
42 | install `mercurial_keyring`_, but you may need to control the process. | |
|
43 | ||
|
44 | The keyring_ library can usually be installed by:: | |
|
40 | 45 | |
|
41 | :: | |
|
46 | pip install --user keyring | |
|
42 | 47 | |
|
43 | easy_install keyring | |
|
48 | (or ``easy_install keyring``), but on some systems it is preferable to | |
|
49 | use official distribution archive. For example, on Debian and Ubuntu, | |
|
50 | you may install ``python-keyring`` and either ``python-keyring-gnome`` | |
|
51 | or ``python-keyring-kwallet`` packages:: | |
|
44 | 52 | |
|
45 | (or ``pip keyring``). On Debian "Sid" the library can be also | |
|
46 | installed from the official archive (packages ``python-keyring`` | |
|
47 | and either ``python-keyring-gnome`` or ``python-keyring-kwallet``). | |
|
53 | sudo apt-get install python-keyring python-keyring-gnome | |
|
54 | ||
|
55 | (this will save you the need to provide working compiler and various | |
|
56 | development libraries). | |
|
48 | 57 | |
|
49 | Note: keyring >= 0.3 is strongly recommended, especially in case text | |
|
50 | backend is to be used. | |
|
58 | The `mercurial_extension_utils`_ module is tiny Python-only module, | |
|
59 | which can be installed by:: | |
|
51 | 60 | |
|
52 | .. _this keyring fork: https://bitbucket.org/sborho/python-keyring-lib | |
|
61 | pip install --user mercurial_extension_utils | |
|
62 | ||
|
63 | but in some cases (Windowsβ¦) require more care. See `mercurial_extension_utils`_ documentation. | |
|
64 | ||
|
53 | 65 | |
|
54 | 66 | Extension installation |
|
55 | 67 | ---------------------- |
|
56 | 68 | |
|
57 | 69 | There are two possible ways of installing the extension: using PyPi package, |
|
58 | or using individual file. | |
|
70 | or using source clone. | |
|
59 | 71 | |
|
60 |
To install as a package |
|
|
61 | ||
|
62 | :: | |
|
72 | To install as a package:: | |
|
63 | 73 | |
|
64 |
|
|
|
74 | pip install --user mercurial_keyring | |
|
65 | 75 | |
|
66 | and then enable it in ``~/.hgrc`` (or ``/etc/mercurial/hgrc``) using: | |
|
67 | ||
|
68 | :: | |
|
76 | (or ``sudo pip install mercurial_keyring`` for system-wide | |
|
77 | installation) and then enable it in ``~/.hgrc`` (or | |
|
78 | ``/etc/mercurial/hgrc`` or ``Mercurial.ini``) using:: | |
|
69 | 79 | |
|
70 | 80 | [extensions] |
|
71 | 81 | mercurial_keyring = |
|
72 | 82 | |
|
73 | To install using individual file, download the | |
|
74 | `mercurial_keyring.py`_ file, save it anywhere you like, and | |
|
75 | put the following in ``~/.hgrc`` (or ``/etc/mercurial/hgrc``): | |
|
83 | To install as source clone, install keyring_ according to instructions above, then | |
|
84 | clone:: | |
|
85 | ||
|
86 | hg clone https://bitbucket.org/Mekk/mercurial_keyring/ | |
|
87 | hg clone https://bitbucket.org/Mekk/mercurial-extension_utils/ | |
|
76 | 88 | |
|
77 | :: | |
|
89 | and configure Mercurial by telling it full path to the extension | |
|
90 | (in ):: | |
|
78 | 91 | |
|
79 | 92 | [extensions] |
|
80 |
|
|
|
93 | mercurial_keyring = /path/to/mercurial_keyring/mercurial_keyring.py | |
|
81 | 94 | |
|
82 | 95 | .. _the code: |
|
83 | 96 | .. _mercurial_keyring.py: http://bitbucket.org/Mekk/mercurial_keyring/src/tip/mercurial_keyring.py |
|
84 | 97 | |
|
85 | 98 | Password backend configuration |
|
86 | 99 | ============================== |
|
87 | 100 | |
|
88 | 101 | The library should usually pick the most appropriate password backend |
|
89 | 102 | without configuration. Still, if necessary, it can be configured using |
|
90 | 103 | ``~/keyringrc.cfg`` file (``keyringrc.cfg`` in the home directory of |
|
91 | 104 | the current user). Refer to keyring_ docs for more details. |
|
92 | 105 | |
|
93 | 106 | *I considered handling similar options in hgrc, but decided that |
|
94 | 107 | single user may use more than one keyring-based script. Still, I am |
|
95 | 108 | open to suggestions.* |
|
96 | 109 | |
|
97 | 110 | Repository configuration (HTTP) |
|
98 | 111 | =============================== |
|
99 | 112 | |
|
100 | 113 | Edit repository-local ``.hg/hgrc`` and save there the remote |
|
101 | 114 | repository path and the username, but do not save the password. For |
|
102 | 115 | example: |
|
103 | 116 | |
|
104 | 117 | :: |
|
105 | 118 | |
|
106 | 119 | [paths] |
|
107 | 120 | myremote = https://my.server.com/hgrepo/someproject |
|
108 | 121 | |
|
109 | 122 | [auth] |
|
110 | 123 | myremote.schemes = http https |
|
111 | 124 | myremote.prefix = my.server.com/hgrepo |
|
112 | 125 | myremote.username = mekk |
|
113 | 126 | |
|
114 | 127 | Simpler form with url-embedded name can also be used: |
|
115 | 128 | |
|
116 | 129 | :: |
|
117 | 130 | |
|
118 | 131 | [paths] |
|
119 | 132 | bitbucket = https://User@bitbucket.org/User/project_name/ |
|
120 | 133 | |
|
121 | 134 | If prefix is specified, it is used to identify the password (so all |
|
122 | 135 | repositories with the same prefix and the same username will share the |
|
123 | 136 | same password). Otherwise full repository URL is used for this |
|
124 | 137 | purpose. |
|
125 | 138 | |
|
126 | 139 | Note: if both username and password are given in ``.hg/hgrc``, |
|
127 | 140 | extension will use them without using the password database. If |
|
128 | 141 | username is not given, extension will prompt for credentials every |
|
129 | 142 | time, also without saving the password. |
|
130 | 143 | |
|
131 | 144 | Finally, if you are consistent about remote repository nicknames, |
|
132 | 145 | you can configure the username in your `~/.hgrc` (`.hgrc` in your |
|
133 | 146 | home directory). For example, write there:: |
|
134 | 147 | |
|
135 | 148 | [auth] |
|
136 | 149 | acme.prefix = hg.acme.com/repositories |
|
137 | 150 | acme.username = johnny |
|
138 | 151 | acme.schemes = http https |
|
139 | 152 | |
|
140 | 153 | and as long as you will be using alias `acme` for repositories like |
|
141 | 154 | `https://hg.acme.com/repositories/my_beautiful_app`, username |
|
142 | 155 | `johnnny` will be used, and the same password reused. |
|
143 | 156 | |
|
144 | 157 | The advantage of this method is that it works also for `clone`. |
|
145 | 158 | |
|
146 | 159 | Repository configuration (SMTP) |
|
147 | 160 | =============================== |
|
148 | 161 | |
|
149 | 162 | Edit either repository-local ``.hg/hgrc``, or ``~/.hgrc`` and set |
|
150 | 163 | there all standard email and smtp properties, including SMTP |
|
151 | 164 | username, but without SMTP password. For example: |
|
152 | 165 | |
|
153 | 166 | :: |
|
154 | 167 | |
|
155 | 168 | [email] |
|
156 | 169 | method = smtp |
|
157 | 170 | from = Joe Doe <Joe.Doe@remote.com> |
|
158 | 171 | |
|
159 | 172 | [smtp] |
|
160 | 173 | host = smtp.gmail.com |
|
161 | 174 | port = 587 |
|
162 | 175 | username = JoeDoe@gmail.com |
|
163 | 176 | tls = true |
|
164 | 177 | |
|
165 | 178 | Just as in case of HTTP, you *must* set username, but *must not* set |
|
166 | 179 | password here to use the extension, in other cases it will revert to |
|
167 | 180 | the default behavior. |
|
168 | 181 | |
|
169 | 182 | Usage |
|
170 | 183 | ===== |
|
171 | 184 | |
|
172 | 185 | Configure the repository as above, then just ``hg pull``, ``hg push``, |
|
173 | 186 | etc. You should be asked for the password only once (per every |
|
174 | 187 | username and remote repository prefix or url combination). |
|
175 | 188 | |
|
176 | 189 | |
|
177 | 190 | Similarly, for email, configure as above and just ``hg email``. |
|
178 | 191 | Again, you will be asked for the password once (per every username and |
|
179 | 192 | email server address combination). |
|
180 | 193 | |
|
181 | 194 | Implementation details |
|
182 | 195 | ====================== |
|
183 | 196 | |
|
184 | 197 | The extension is monkey-patching the mercurial ``passwordmgr`` class |
|
185 | 198 | to replace the find_user_password method. Detailed order of operations |
|
186 | 199 | is described in the comments inside `the code`_. |
|
187 | 200 | |
|
188 | 201 | History |
|
189 | 202 | ========== |
|
190 | 203 | |
|
191 | 204 | See `HISTORY.txt`_. |
|
192 | 205 | |
|
193 | 206 | Development |
|
194 | 207 | =========== |
|
195 | 208 | |
|
196 | 209 | Development is tracked on BitBucket, see |
|
197 | 210 | http://bitbucket.org/Mekk/mercurial_keyring/ |
|
198 | 211 | |
|
199 | 212 | |
|
200 | 213 | Additional notes |
|
201 | 214 | ================ |
|
202 | 215 | |
|
203 | 216 | Information about this extension is also available |
|
204 | 217 | on Mercurial Wiki: http://mercurial.selenic.com/wiki/KeyringExtension |
|
205 | 218 | |
|
206 | 219 | .. _HISTORY.txt: http://bitbucket.org/Mekk/mercurial_keyring/src/tip/HISTORY.txt |
|
220 | .. _TortoiseHg: http://tortoisehg.bitbucket.org/ | |
|
221 | .. _Mercurial: http://mercurial.selenic.com | |
|
222 | .. _mercurial_extension_utils: https://bitbucket.org/Mekk/mercurial-extension_utils/ |
@@ -1,42 +1,42 b'' | |||
|
1 | 1 | |
|
2 | 2 | VERSION = '0.7.1' |
|
3 | 3 | |
|
4 | 4 | # pylint: disable=unused-import |
|
5 | 5 | |
|
6 | 6 | try: |
|
7 | 7 | from setuptools import setup, find_packages |
|
8 | 8 | except ImportError: |
|
9 | 9 | from ez_setup import use_setuptools |
|
10 | 10 | use_setuptools() |
|
11 | 11 | from setuptools import setup, find_packages |
|
12 | 12 | |
|
13 | 13 | LONG_DESCRIPTION = open("README.txt").read() |
|
14 | 14 | |
|
15 | 15 | setup( |
|
16 | 16 | name="mercurial_keyring", |
|
17 | 17 | version=VERSION, |
|
18 | 18 | author='Marcin Kasperski', |
|
19 | 19 | author_email='Marcin.Kasperski@mekk.waw.pl', |
|
20 | 20 | url='http://bitbucket.org/Mekk/mercurial_keyring', |
|
21 | 21 | description='Mercurial Keyring Extension', |
|
22 | 22 | long_description=LONG_DESCRIPTION, |
|
23 | 23 | license='BSD', |
|
24 | 24 | py_modules=['mercurial_keyring'], |
|
25 | 25 | keywords="mercurial hg keyring password", |
|
26 | 26 | classifiers=[ |
|
27 | 27 | 'Development Status :: 4 - Beta', |
|
28 | 28 | 'Environment :: Console', |
|
29 | 29 | 'Intended Audience :: Developers', |
|
30 | 30 | 'License :: DFSG approved', |
|
31 | 31 | 'License :: OSI Approved :: BSD License', |
|
32 | 32 | 'Operating System :: OS Independent', |
|
33 | 33 | 'Topic :: Software Development :: Libraries', |
|
34 | 34 | 'Topic :: Software Development :: Libraries :: Python Modules', |
|
35 | 35 | 'Topic :: Software Development :: Version Control' |
|
36 | 36 | ], |
|
37 | 37 | install_requires=[ |
|
38 | 38 | 'keyring>=0.3', |
|
39 |
'mercurial_extension_utils>=0. |
|
|
39 | 'mercurial_extension_utils>=0.10.0', | |
|
40 | 40 | ], |
|
41 | 41 | zip_safe=True, |
|
42 | 42 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now