Show More
@@ -1,431 +1,431 b'' | |||||
1 | .. -*- mode: rst; compile-command: "rst2html README.rst README.html" -*- |
|
1 | .. -*- mode: rst; compile-command: "rst2html README.rst README.html" -*- | |
2 |
|
2 | |||
3 | ======================================================= |
|
3 | ======================================================= | |
4 | Mercurial Keyring |
|
4 | Mercurial Keyring | |
5 | ======================================================= |
|
5 | ======================================================= | |
6 |
|
6 | |||
7 | Mercurial Keyring is a Mercurial_ extension used to securely save HTTP |
|
7 | Mercurial Keyring is a Mercurial_ extension used to securely save HTTP | |
8 | and SMTP authentication passwords in password databases (Gnome |
|
8 | and SMTP authentication passwords in password databases (Gnome | |
9 | Keyring, KDE KWallet, OSXKeyChain, Windows Vault etc). |
|
9 | Keyring, KDE KWallet, OSXKeyChain, Windows Vault etc). | |
10 |
|
10 | |||
11 | With ``mercurial_keyring`` active, Mercurial remembers your passwords |
|
11 | With ``mercurial_keyring`` active, Mercurial remembers your passwords | |
12 | and reuses them without prompting (as if you stored them in ``.hgrc``), |
|
12 | and reuses them without prompting (as if you stored them in ``.hgrc``), | |
13 | but password storage is reasonably secure. |
|
13 | but password storage is reasonably secure. | |
14 |
|
14 | |||
15 | Actual password storage is implemented by the keyring_ library, this |
|
15 | Actual password storage is implemented by the keyring_ library, this | |
16 | extension glues it to Mercurial. |
|
16 | extension glues it to Mercurial. | |
17 |
|
17 | |||
18 | .. contents:: |
|
18 | .. contents:: | |
19 | :local: |
|
19 | :local: | |
20 | :depth: 2 |
|
20 | :depth: 2 | |
21 |
|
21 | |||
22 | .. sectnum:: |
|
22 | .. sectnum:: | |
23 |
|
23 | |||
24 | .. _keyring: http://pypi.python.org/pypi/keyring |
|
24 | .. _keyring: http://pypi.python.org/pypi/keyring | |
25 | .. _Mercurial: http://mercurial.selenic.com |
|
25 | .. _Mercurial: http://mercurial.selenic.com | |
26 |
|
26 | |||
27 | How does it work |
|
27 | How does it work | |
28 | ======================================================= |
|
28 | ======================================================= | |
29 |
|
29 | |||
30 | On your first pull or push to HTTP url (or first email sent via given |
|
30 | On your first pull or push to HTTP url (or first email sent via given | |
31 | SMTP server), you are prompted for the password, just like bare |
|
31 | SMTP server), you are prompted for the password, just like bare | |
32 | Mercurial does. But the password you entered is saved to appropriate |
|
32 | Mercurial does. But the password you entered is saved to appropriate | |
33 | password database. On successive runs, whenever the password is |
|
33 | password database. On successive runs, whenever the password is | |
34 | needed, ``mercurial_keyring`` checks for password in password |
|
34 | needed, ``mercurial_keyring`` checks for password in password | |
35 | database, and uses it without troubling you. |
|
35 | database, and uses it without troubling you. | |
36 |
|
36 | |||
37 | In case password turns out to be incorrect (for example, because you |
|
37 | In case password turns out to be incorrect (for example, because you | |
38 | changed it, or entered it incorrectly), ``mercurial_keyring`` prompts |
|
38 | changed it, or entered it incorrectly), ``mercurial_keyring`` prompts | |
39 | you again, and overwrites the password. |
|
39 | you again, and overwrites the password. | |
40 |
|
40 | |||
41 | You can use many passwords (for various remote urls). Saved passwords |
|
41 | You can use many passwords (for various remote urls). Saved passwords | |
42 | are identified by pair of username and url prefix. See below for |
|
42 | are identified by pair of username and url prefix. See below for | |
43 | information how to configure those properly. |
|
43 | information how to configure those properly. | |
44 |
|
44 | |||
45 | Installation |
|
45 | Installation | |
46 | ======================================================= |
|
46 | ======================================================= | |
47 |
|
47 | |||
48 | Prerequisites |
|
48 | Prerequisites | |
49 | ------------- |
|
49 | ------------- | |
50 |
|
50 | |||
51 | This extension requires keyring_ and `mercurial_extension_utils`_ to |
|
51 | This extension requires keyring_ and `mercurial_extension_utils`_ to | |
52 | work. In many cases both will be installed automatically while you |
|
52 | work. In many cases both will be installed automatically while you | |
53 | install ``mercurial_keyring``, but you may need to control the process. |
|
53 | install ``mercurial_keyring``, but you may need to control the process. | |
54 |
|
54 | |||
55 | The keyring_ library can usually be installed by:: |
|
55 | The keyring_ library can usually be installed by:: | |
56 |
|
56 | |||
57 | pip install --user keyring |
|
57 | pip install --user keyring | |
58 |
|
58 | |||
59 | (or ``easy_install keyring``), but on some systems it is preferable to |
|
59 | (or ``easy_install keyring``), but on some systems it is preferable to | |
60 | use official distribution archive. For example, on Debian and Ubuntu, |
|
60 | use official distribution archive. For example, on Debian and Ubuntu, | |
61 | you may install ``python-keyring`` and either ``python-keyring-gnome`` |
|
61 | you may install ``python-keyring`` and either ``python-keyring-gnome`` | |
62 | or ``python-keyring-kwallet`` packages:: |
|
62 | or ``python-keyring-kwallet`` packages:: | |
63 |
|
63 | |||
64 | sudo apt-get install python-keyring python-keyring-gnome |
|
64 | sudo apt-get install python-keyring python-keyring-gnome | |
65 |
|
65 | |||
66 | (this will save you the need to provide working compiler and various |
|
66 | (this will save you the need to provide working compiler and various | |
67 | development libraries). |
|
67 | development libraries). | |
68 |
|
68 | |||
69 | The `mercurial_extension_utils`_ module is tiny Python-only module, |
|
69 | The `mercurial_extension_utils`_ module is tiny Python-only module, | |
70 | which can be installed by:: |
|
70 | which can be installed by:: | |
71 |
|
71 | |||
72 | pip install --user mercurial_extension_utils |
|
72 | pip install --user mercurial_extension_utils | |
73 |
|
73 | |||
74 | but in some cases (Windowsβ¦) requires more care. See |
|
74 | but in some cases (Windowsβ¦) requires more care. See | |
75 | `mercurial_extension_utils`_ documentation. |
|
75 | `mercurial_extension_utils`_ documentation. | |
76 |
|
76 | |||
77 |
|
77 | |||
78 | Extension installation |
|
78 | Extension installation | |
79 | ---------------------- |
|
79 | ---------------------- | |
80 |
|
80 | |||
81 | There are two possible ways of installing the extension: using PyPi package, |
|
81 | There are two possible ways of installing the extension: using PyPi package, | |
82 | or using source clone. |
|
82 | or using source clone. | |
83 |
|
83 | |||
84 | To install as a package:: |
|
84 | To install as a package:: | |
85 |
|
85 | |||
86 | pip install --user mercurial_keyring |
|
86 | pip install --user mercurial_keyring | |
87 |
|
87 | |||
88 | (or ``sudo pip install mercurial_keyring`` for system-wide |
|
88 | (or ``sudo pip install mercurial_keyring`` for system-wide | |
89 | installation) and then enable it in ``~/.hgrc`` (or |
|
89 | installation) and then enable it in ``~/.hgrc`` (or | |
90 | ``/etc/mercurial/hgrc`` or ``Mercurial.ini``) using:: |
|
90 | ``/etc/mercurial/hgrc`` or ``Mercurial.ini``) using:: | |
91 |
|
91 | |||
92 | [extensions] |
|
92 | [extensions] | |
93 | mercurial_keyring = |
|
93 | mercurial_keyring = | |
94 |
|
94 | |||
95 | To install using source clone, install keyring_ according to the |
|
95 | To install using source clone, install keyring_ according to the | |
96 | instructions above, then clone:: |
|
96 | instructions above, then clone:: | |
97 |
|
97 | |||
98 | hg clone https://foss.heptapod.net/mercurial/mercurial_keyring/ |
|
98 | hg clone https://foss.heptapod.net/mercurial/mercurial_keyring/ | |
99 | hg clone https://foss.heptapod.net/mercurial/mercurial-extension_utils/ |
|
99 | hg clone https://foss.heptapod.net/mercurial/mercurial-extension_utils/ | |
100 |
|
100 | |||
101 | and configure Mercurial using full path to the extension module:: |
|
101 | and configure Mercurial using full path to the extension module:: | |
102 |
|
102 | |||
103 | [extensions] |
|
103 | [extensions] | |
104 | mercurial_keyring = /path/to/mercurial_keyring/mercurial_keyring.py |
|
104 | mercurial_keyring = /path/to/mercurial_keyring/mercurial_keyring.py | |
105 |
|
105 | |||
106 | .. _the code: |
|
106 | .. _the code: | |
107 | .. _mercurial_keyring.py: https://foss.heptapod.net/mercurial/mercurial_keyring/src/tip/mercurial_keyring.py |
|
107 | .. _mercurial_keyring.py: https://foss.heptapod.net/mercurial/mercurial_keyring/src/tip/mercurial_keyring.py | |
108 |
|
108 | |||
109 | Password backend configuration |
|
109 | Password backend configuration | |
110 | ======================================================= |
|
110 | ======================================================= | |
111 |
|
111 | |||
112 | The most appropriate password backend should usually be picked without |
|
112 | The most appropriate password backend should usually be picked without | |
113 | configuration (considering installed libraries, operating system, |
|
113 | configuration (considering installed libraries, operating system, | |
114 | active desktop session). Still, if necessary, it can be configured |
|
114 | active desktop session). Still, if necessary, it can be configured | |
115 | using ``keyringrc.cfg`` file. Refer to keyring_ docs for more |
|
115 | using ``keyringrc.cfg`` file. Refer to keyring_ docs for more | |
116 | details. |
|
116 | details. | |
117 |
|
117 | |||
118 | .. note:: |
|
118 | .. note:: | |
119 |
|
119 | |||
120 | With current (as I write) keyring (5.6), this file is (on Linux) |
|
120 | With current (as I write) keyring (5.6), this file is (on Linux) | |
121 | located at ``~/.local/share/python_keyring/keyringrc.cfg`` and |
|
121 | located at ``~/.local/share/python_keyring/keyringrc.cfg`` and | |
122 | it's example content looks like:: |
|
122 | it's example content looks like:: | |
123 |
|
123 | |||
124 | [backend] |
|
124 | [backend] | |
125 | default-keyring=keyring.backends.Gnome.Keyring |
|
125 | default-keyring=keyring.backends.Gnome.Keyring | |
126 | # default-keyring=keyring.backends.kwallet.Keyring |
|
126 | # default-keyring=keyring.backends.kwallet.Keyring | |
127 |
|
127 | |||
128 | For list of known backends run ``pydoc keyring.backends`` or |
|
128 | For list of known backends run ``pydoc keyring.backends`` or | |
129 | ``keyring --list-backends`` (which of those commands work, |
|
129 | ``keyring --list-backends`` (which of those commands work, | |
130 | depends on the keyring_ version). |
|
130 | depends on the keyring_ version). | |
131 |
|
131 | |||
132 |
|
132 | |||
133 | ``hgrc`` configuration (HTTP) |
|
133 | ``hgrc`` configuration (HTTP) | |
134 | ======================================================= |
|
134 | ======================================================= | |
135 |
|
135 | |||
136 | Mercurial Keyring uses standard Mercurial ``[auth]`` configuration to |
|
136 | Mercurial Keyring uses standard Mercurial ``[auth]`` configuration to | |
137 | detect your username (on given remote) and url prefix. You are |
|
137 | detect your username (on given remote) and url prefix. You are | |
138 | strongly advised to configure both. |
|
138 | strongly advised to configure both. | |
139 |
|
139 | |||
140 | Without the username ``mercurial_keyring`` can't save or restore |
|
140 | Without the username ``mercurial_keyring`` can't save or restore | |
141 | passwords, so it disables itself. |
|
141 | passwords, so it disables itself. | |
142 |
|
142 | |||
143 | Without url prefix ``mercurial_keyring`` works, but binds passwords to |
|
143 | Without url prefix ``mercurial_keyring`` works, but binds passwords to | |
144 | repository urls. That means you will have to (re)enter password for |
|
144 | repository urls. That means you will have to (re)enter password for | |
145 | every repository cloned from given remote (and that there will be many |
|
145 | every repository cloned from given remote (and that there will be many | |
146 | copies of this password in secure storage). |
|
146 | copies of this password in secure storage). | |
147 |
|
147 | |||
148 | Repository level configuration |
|
148 | Repository level configuration | |
149 | ------------------------------------ |
|
149 | ------------------------------------ | |
150 |
|
150 | |||
151 | Edit repository-local ``.hg/hgrc`` and save there the remote |
|
151 | Edit repository-local ``.hg/hgrc`` and save there the remote | |
152 | repository path and the username, but do not save the password. For |
|
152 | repository path and the username, but do not save the password. For | |
153 | example: |
|
153 | example: | |
154 |
|
154 | |||
155 | :: |
|
155 | :: | |
156 |
|
156 | |||
157 | [paths] |
|
157 | [paths] | |
158 | myremote = https://my.server.com/hgrepo/someproject |
|
158 | myremote = https://my.server.com/hgrepo/someproject | |
159 |
|
159 | |||
160 | [auth] |
|
160 | [auth] | |
161 | myremote.prefix = https://my.server.com/hgrepo |
|
161 | myremote.prefix = https://my.server.com/hgrepo | |
162 | myremote.username = John |
|
162 | myremote.username = John | |
163 |
|
163 | |||
164 | Simpler form with url-embedded name can also be used: |
|
164 | Simpler form with url-embedded name can also be used: | |
165 |
|
165 | |||
166 | :: |
|
166 | :: | |
167 |
|
167 | |||
168 | [paths] |
|
168 | [paths] | |
169 | bitbucket = https://John@my.server.com/hgrepo/someproject/ |
|
169 | bitbucket = https://John@my.server.com/hgrepo/someproject/ | |
170 |
|
170 | |||
171 | but is not recommended. |
|
171 | but is not recommended. | |
172 |
|
172 | |||
173 | Note that all repositories sharing the same ``prefix`` share the same |
|
173 | Note that all repositories sharing the same ``prefix`` share the same | |
174 | password. |
|
174 | password. | |
175 |
|
175 | |||
176 | Mercurial allows also for password in ``.hg/hgrc`` (either given by |
|
176 | Mercurial allows also for password in ``.hg/hgrc`` (either given by | |
177 | ``Β«prefixΒ».password``, or embedded in url). If such password is found, |
|
177 | ``Β«prefixΒ».password``, or embedded in url). If such password is found, | |
178 | Mercurial Keyring disables itself. |
|
178 | Mercurial Keyring disables itself. | |
179 |
|
179 | |||
180 |
|
180 | |||
181 | Account-level configuration |
|
181 | Account-level configuration | |
182 | --------------------------- |
|
182 | --------------------------- | |
183 |
|
183 | |||
184 | If you are consistent about remote repository nicknames, you can |
|
184 | If you are consistent about remote repository nicknames, you can | |
185 | configure the username in your `~/.hgrc` (`.hgrc` in your home |
|
185 | configure the username in your `~/.hgrc` (`.hgrc` in your home | |
186 | directory). For example, write there:: |
|
186 | directory). For example, write there:: | |
187 |
|
187 | |||
188 | [auth] |
|
188 | [auth] | |
189 | acme.prefix = hg.acme.com/repositories |
|
189 | acme.prefix = hg.acme.com/repositories | |
190 | acme.username = johnny |
|
190 | acme.username = johnny | |
191 | acme.schemes = http https |
|
191 | acme.schemes = http https | |
192 | bitbucket.prefix = https://bitbucket.org |
|
192 | bitbucket.prefix = https://bitbucket.org | |
193 | bitbucket.username = Mekk |
|
193 | bitbucket.username = Mekk | |
194 | mydep.prefix = https://dev.acmeorg.com |
|
194 | mydep.prefix = https://dev.acmeorg.com | |
195 | mydep.username = drmartin |
|
195 | mydep.username = drmartin | |
196 |
|
196 | |||
197 | and as long as you use ``acme`` alias for repositories like |
|
197 | and as long as you use ``acme`` alias for repositories like | |
198 | ``https://hg.acme.com/repositories/my_beautiful_app``, username |
|
198 | ``https://hg.acme.com/repositories/my_beautiful_app``, username | |
199 | ``johnny`` will be used, and the same password reused. Similarly |
|
199 | ``johnny`` will be used, and the same password reused. Similarly | |
200 | any ``hg push bitbucket`` will share the same password. |
|
200 | any ``hg push bitbucket`` will share the same password. | |
201 |
|
201 | |||
202 | With such config repository-level ``.hg/hgrc`` need only contain |
|
202 | With such config repository-level ``.hg/hgrc`` need only contain | |
203 | ``[paths]``. |
|
203 | ``[paths]``. | |
204 |
|
204 | |||
205 | Additional advantage of this method is that it works also during |
|
205 | Additional advantage of this method is that it works also during | |
206 | `clone`. |
|
206 | `clone`. | |
207 |
|
207 | |||
208 |
|
208 | |||
209 | .. note:: |
|
209 | .. note:: | |
210 |
|
210 | |||
211 | Mercurial Keyring works well with `Path Pattern`_. On my setup I use |
|
211 | Mercurial Keyring works well with `Path Pattern`_. On my setup I use | |
212 | prefix as above, and:: |
|
212 | prefix as above, and:: | |
213 |
|
213 | |||
214 | [path_pattern] |
|
214 | [path_pattern] | |
215 | bitbucket.local = ~/devel/{below} |
|
215 | bitbucket.local = ~/devel/{below} | |
216 | bitbucket.remote = https://bitbucket.org/Mekk/{below:/=-} |
|
216 | bitbucket.remote = https://bitbucket.org/Mekk/{below:/=-} | |
217 |
|
217 | |||
218 | so all my repositories understand ``hg push bitbucket`` without |
|
218 | so all my repositories understand ``hg push bitbucket`` without | |
219 | any repository-level configuration. |
|
219 | any repository-level configuration. | |
220 |
|
220 | |||
221 |
|
221 | |||
222 | ``hgrc`` configuration (SMTP) |
|
222 | ``hgrc`` configuration (SMTP) | |
223 | ======================================================= |
|
223 | ======================================================= | |
224 |
|
224 | |||
225 | Edit either repository-local ``.hg/hgrc``, or ``~/.hgrc`` and set |
|
225 | Edit either repository-local ``.hg/hgrc``, or ``~/.hgrc`` and set | |
226 | there all standard email and smtp properties, including SMTP |
|
226 | there all standard email and smtp properties, including SMTP | |
227 | username, but without SMTP password. For example: |
|
227 | username, but without SMTP password. For example: | |
228 |
|
228 | |||
229 | :: |
|
229 | :: | |
230 |
|
230 | |||
231 | [email] |
|
231 | [email] | |
232 | method = smtp |
|
232 | method = smtp | |
233 | from = Joe Doe <Joe.Doe@remote.com> |
|
233 | from = Joe Doe <Joe.Doe@remote.com> | |
234 |
|
234 | |||
235 | [smtp] |
|
235 | [smtp] | |
236 | host = smtp.gmail.com |
|
236 | host = smtp.gmail.com | |
237 | port = 587 |
|
237 | port = 587 | |
238 | username = JoeDoe@gmail.com |
|
238 | username = JoeDoe@gmail.com | |
239 | tls = true |
|
239 | tls = true | |
240 |
|
240 | |||
241 | Just as in case of HTTP, you *must* set username, but *must not* set |
|
241 | Just as in case of HTTP, you *must* set username, but *must not* set | |
242 | password here to use the extension, in other cases it will revert to |
|
242 | password here to use the extension, in other cases it will revert to | |
243 | the default behavior. |
|
243 | the default behavior. | |
244 |
|
244 | |||
245 | Usage |
|
245 | Usage | |
246 | ====================================================== |
|
246 | ====================================================== | |
247 |
|
247 | |||
248 | Saving and restoring passwords |
|
248 | Saving and restoring passwords | |
249 | ------------------------------------------------------- |
|
249 | ------------------------------------------------------- | |
250 |
|
250 | |||
251 | Configure the repository as above, then just ``hg pull``, ``hg push``, |
|
251 | Configure the repository as above, then just ``hg pull``, ``hg push``, | |
252 | etc. You should be asked for the password only once (per every |
|
252 | etc. You should be asked for the password only once (per every | |
253 | username and remote repository prefix or url combination). |
|
253 | username and remote repository prefix or url combination). | |
254 |
|
254 | |||
255 | Similarly, for email, configure as above and just ``hg email``. |
|
255 | Similarly, for email, configure as above and just ``hg email``. | |
256 | Again, you will be asked for the password once (per every username and |
|
256 | Again, you will be asked for the password once (per every username and | |
257 | email server address combination). |
|
257 | email server address combination). | |
258 |
|
258 | |||
259 | Checking password status (``hg keyring_check``) |
|
259 | Checking password status (``hg keyring_check``) | |
260 | ------------------------------------------------------- |
|
260 | ------------------------------------------------------- | |
261 |
|
261 | |||
262 | The ``keyring_check`` command can be used to check whether/which |
|
262 | The ``keyring_check`` command can be used to check whether/which | |
263 | password(s) are saved. It can be used in three ways: |
|
263 | password(s) are saved. It can be used in three ways: | |
264 |
|
264 | |||
265 | - without parameters, it prints info related to all HTTP paths |
|
265 | - without parameters, it prints info related to all HTTP paths | |
266 | defined for current repository (everything from ``hg paths`` |
|
266 | defined for current repository (everything from ``hg paths`` | |
267 | that resolves to HTTP url):: |
|
267 | that resolves to HTTP url):: | |
268 |
|
268 | |||
269 | hg keyring_check |
|
269 | hg keyring_check | |
270 |
|
270 | |||
271 | - given alias as param, it prints info about this alias:: |
|
271 | - given alias as param, it prints info about this alias:: | |
272 |
|
272 | |||
273 | hg keyring_check work |
|
273 | hg keyring_check work | |
274 |
|
274 | |||
275 | - finally, any path can be checked:: |
|
275 | - finally, any path can be checked:: | |
276 |
|
276 | |||
277 | hg keyring_check https://foss.heptapod.net/mercurial/mercurial_keyring |
|
277 | hg keyring_check https://foss.heptapod.net/mercurial/mercurial_keyring | |
278 |
|
278 | |||
279 | Deleting saved password (``hg keyring_clear``) |
|
279 | Deleting saved password (``hg keyring_clear``) | |
280 | ------------------------------------------------------- |
|
280 | ------------------------------------------------------- | |
281 |
|
281 | |||
282 | The ``keyring_clear`` command removes saved password related to given |
|
282 | The ``keyring_clear`` command removes saved password related to given | |
283 | path. It can be used in two ways: |
|
283 | path. It can be used in two ways: | |
284 |
|
284 | |||
285 | - given alias as param, it drops password used by this alias:: |
|
285 | - given alias as param, it drops password used by this alias:: | |
286 |
|
286 | |||
287 | hg keyring_clear work |
|
287 | hg keyring_clear work | |
288 |
|
288 | |||
289 | - given full path, it drops password related to this path:: |
|
289 | - given full path, it drops password related to this path:: | |
290 |
|
290 | |||
291 | hg keyring_clear https://foss.heptapod.net/mercurial/mercurial_keyring |
|
291 | hg keyring_clear https://foss.heptapod.net/mercurial/mercurial_keyring | |
292 |
|
292 | |||
293 | Managing passwords using GUI tools |
|
293 | Managing passwords using GUI tools | |
294 | ------------------------------------------------------ |
|
294 | ------------------------------------------------------ | |
295 |
|
295 | |||
296 | Many password backends provide GUI tools for password management, |
|
296 | Many password backends provide GUI tools for password management, | |
297 | for example Gnome Keyring passwords can be managed using ``seahorse``, |
|
297 | for example Gnome Keyring passwords can be managed using ``seahorse``, | |
298 | and KDE Wallet using ``kwalletmanager``. Those GUI tools can be used |
|
298 | and KDE Wallet using ``kwalletmanager``. Those GUI tools can be used | |
299 | to review, edit, or delete saved passwords. |
|
299 | to review, edit, or delete saved passwords. | |
300 |
|
300 | |||
301 | Unfortunately, as I write, keyring_ library does not allow one to |
|
301 | Unfortunately, as I write, keyring_ library does not allow one to | |
302 | configure how/where exactly saved passwords are put in the hierarchy, |
|
302 | configure how/where exactly saved passwords are put in the hierarchy, | |
303 | and the place is not always intuitive. For example, in KDE Wallet, all |
|
303 | and the place is not always intuitive. For example, in KDE Wallet, all | |
304 | passwords saved using ``mercurial_keyring`` show up in the folder |
|
304 | passwords saved using ``mercurial_keyring`` show up in the folder | |
305 | named ``Python``. |
|
305 | named ``Python``. | |
306 |
|
306 | |||
307 | .. note:: |
|
307 | .. note:: | |
308 |
|
308 | |||
309 | This is slightly problematic in case ``mercurial_keyring`` is not |
|
309 | This is slightly problematic in case ``mercurial_keyring`` is not | |
310 | the only program using keyring_ library. Passwords saved by another |
|
310 | the only program using keyring_ library. Passwords saved by another | |
311 | Python application or script (which also uses keyring_) will be put |
|
311 | Python application or script (which also uses keyring_) will be put | |
312 | into the same place, and it may be unclear which password belongs |
|
312 | into the same place, and it may be unclear which password belongs | |
313 | to which program. To remedy this, ``mercurial_keyring`` applies |
|
313 | to which program. To remedy this, ``mercurial_keyring`` applies | |
314 | slightly unusual labels of the form |
|
314 | slightly unusual labels of the form | |
315 | ``Β«usernameΒ»ο»Ώ@@ο»ΏΒ«urlprefixΒ»ο»Ώ@ο»ΏMercurial`` - for example my bitbucket |
|
315 | ``Β«usernameΒ»ο»Ώ@@ο»ΏΒ«urlprefixΒ»ο»Ώ@ο»ΏMercurial`` - for example my bitbucket | |
316 | password is labelled ``Mekkο»Ώ@@ο»Ώhttpsο»Ώ://ο»Ώbitbucket.orgο»Ώ@ο»ΏMercurial``. |
|
316 | password is labelled ``Mekkο»Ώ@@ο»Ώhttpsο»Ώ://ο»Ώbitbucket.orgο»Ώ@ο»ΏMercurial``. | |
317 |
|
317 | |||
318 | Implementation details |
|
318 | Implementation details | |
319 | ======================================================= |
|
319 | ======================================================= | |
320 |
|
320 | |||
321 | The extension is monkey-patching the mercurial ``passwordmgr`` class |
|
321 | The extension is monkey-patching the mercurial ``passwordmgr`` class | |
322 | to replace the ``find_user_password`` method. Detailed order of operations |
|
322 | to replace the ``find_user_password`` method. Detailed order of operations | |
323 | is described in the comments inside `the code`_. |
|
323 | is described in the comments inside `the code`_. | |
324 |
|
324 | |||
325 | Frequent problems |
|
325 | Frequent problems | |
326 | ======================================================= |
|
326 | ======================================================= | |
327 |
|
327 | |||
328 | Most problems people face while using ``mercurial_keyring`` are in |
|
328 | Most problems people face while using ``mercurial_keyring`` are in | |
329 | fact problems with ``keyring`` library and it's backends. In |
|
329 | fact problems with ``keyring`` library and it's backends. In | |
330 | particular, those can manifest by: |
|
330 | particular, those can manifest by: | |
331 |
|
331 | |||
332 | - technical errors mentioning sentences like ``No recommended backend |
|
332 | - technical errors mentioning sentences like ``No recommended backend | |
333 | was available. Install the keyrings.alt packageβ¦`` (or similar), |
|
333 | was available. Install the keyrings.alt packageβ¦`` (or similar), | |
334 |
|
334 | |||
335 | - warnings like ``keyring: keyring backend doesn't seem to workβ¦`` |
|
335 | - warnings like ``keyring: keyring backend doesn't seem to workβ¦`` | |
336 |
|
336 | |||
337 | - password prompts on every action (= passwords not being saved). |
|
337 | - password prompts on every action (= passwords not being saved). | |
338 |
|
338 | |||
339 | Those almost always mean that *natural* keyring backend for given |
|
339 | Those almost always mean that *natural* keyring backend for given | |
340 | desktop type doesn't work, or is not present at all. For example, |
|
340 | desktop type doesn't work, or is not present at all. For example, | |
341 | some necessary runtime component can be down (say, you use Linux, but |
|
341 | some necessary runtime component can be down (say, you use Linux, but | |
342 | neither Gnome Keyring, nor KDE Wallet, is running). Or appropriate |
|
342 | neither Gnome Keyring, nor KDE Wallet, is running). Or appropriate | |
343 | backend is not installed because it could not be build during keyring_ |
|
343 | backend is not installed because it could not be build during keyring_ | |
344 | library installation (maybe because some required library was not |
|
344 | library installation (maybe because some required library was not | |
345 | present at the moment of keyring installation, or maybe because |
|
345 | present at the moment of keyring installation, or maybe because | |
346 | compiler as such is not present on the system). |
|
346 | compiler as such is not present on the system). | |
347 |
|
347 | |||
348 | To diagnose such problems, try using ``keyring`` utility, as described |
|
348 | To diagnose such problems, try using ``keyring`` utility, as described | |
349 | on keyring_ documentation page, for example by:: |
|
349 | on keyring_ documentation page, for example by:: | |
350 |
|
350 | |||
351 | keyring --list-backends |
|
351 | keyring --list-backends | |
352 | keyring -b keyrings.alt.Gnome.Keyring set testsvc testuser |
|
352 | keyring -b keyrings.alt.Gnome.Keyring set testsvc testuser | |
353 | keyring -b keyrings.alt.Gnome.Keyring get testsvc testuser |
|
353 | keyring -b keyrings.alt.Gnome.Keyring get testsvc testuser | |
354 |
|
354 | |||
355 | (of course using appropriate backend). If you miss the ``keyring`` command |
|
355 | (of course using appropriate backend). If you miss the ``keyring`` command | |
356 | as such, try ``python -m keyring`` instead:: |
|
356 | as such, try ``python -m keyring`` instead:: | |
357 |
|
357 | |||
358 | python -m keyring --list-backends |
|
358 | python -m keyring --list-backends | |
359 | python -m keyring -b keyrings.alt.Gnome.Keyring set testsvc testuser |
|
359 | python -m keyring -b keyrings.alt.Gnome.Keyring set testsvc testuser | |
360 | python -m keyring -b keyrings.alt.Gnome.Keyring get testsvc testuser |
|
360 | python -m keyring -b keyrings.alt.Gnome.Keyring get testsvc testuser | |
361 |
|
361 | |||
362 | If appropriate backend is missing (not listed), or doesn't work |
|
362 | If appropriate backend is missing (not listed), or doesn't work | |
363 | (second or third command fails), your keyring is broken. Try looking |
|
363 | (second or third command fails), your keyring is broken. Try looking | |
364 | for further pointers in keyring_ documentation, that project mailing |
|
364 | for further pointers in keyring_ documentation, that project mailing | |
365 | list, or issue tracker. Typically it will turn out, that you need to |
|
365 | list, or issue tracker. Typically it will turn out, that you need to | |
366 | install some missing tool, or library, and reinstall keyring. |
|
366 | install some missing tool, or library, and reinstall keyring. | |
367 |
|
367 | |||
368 | .. note:: |
|
368 | .. note:: | |
369 |
|
369 | |||
370 | Depending on keyring_ version, installation of some dependency may |
|
370 | Depending on keyring_ version, installation of some dependency may | |
371 | resolve problem. For example (as of late 2018), I got KDE Wallet |
|
371 | resolve problem. For example (as of late 2018), I got KDE Wallet | |
372 | backend working with pip-installed keyring after:: |
|
372 | backend working with pip-installed keyring after:: | |
373 |
|
373 | |||
374 | pip install dbus-python |
|
374 | pip install dbus-python | |
375 |
|
375 | |||
376 | Note also, that recent versions of keyring library (since version 12) use Python |
|
376 | Note also, that recent versions of keyring library (since version 12) use Python | |
377 | entrypoints to find available backends. Those are incompatible with |
|
377 | entrypoints to find available backends. Those are incompatible with | |
378 | some binary packaging methods (like ``py2app``) and may cause |
|
378 | some binary packaging methods (like ``py2app``) and may cause | |
379 | problems. In particular there were packaged installations of TortoiseHG |
|
379 | problems. In particular there were packaged installations of TortoiseHG | |
380 | which were unable to load keyring backends. See `#61 <https://foss.heptapod.net/mercurial/mercurial_keyring/issues/61/tortoisehg-encounters-unknown-exception>`_ for some more details. |
|
380 | which were unable to load keyring backends. See `#61 <https://foss.heptapod.net/mercurial/mercurial_keyring/issues/61/tortoisehg-encounters-unknown-exception>`_ for some more details. | |
381 |
|
381 | |||
382 |
|
382 | |||
383 | If ``keyring`` command works, but mercurial with mercurial_keyring does not, |
|
383 | If ``keyring`` command works, but mercurial with mercurial_keyring does not, | |
384 | try enforcing proper backend (by means of ``keyringrc.cfg``, see above). |
|
384 | try enforcing proper backend (by means of ``keyringrc.cfg``, see above). | |
385 | Only if this doesn't help, there may be a bug in mercurial_keyring. |
|
385 | Only if this doesn't help, there may be a bug in mercurial_keyring. | |
386 |
|
386 | |||
387 | By far easiest way to have properly working keyring is to use packaged |
|
387 | By far easiest way to have properly working keyring is to use packaged | |
388 | binary version (like ``python-keyring`` Ubuntu package, or keyring |
|
388 | binary version (like ``python-keyring`` Ubuntu package, or keyring | |
389 | bundled with TortoiseHG on some systems). If you pip-installed keyring |
|
389 | bundled with TortoiseHG on some systems). If you pip-installed keyring | |
390 | and it doesn't work, you may consider removing it via ``pip uninstall |
|
390 | and it doesn't work, you may consider removing it via ``pip uninstall | |
391 | keyring`` and looking for binary package instead. |
|
391 | keyring`` and looking for binary package instead. | |
392 |
|
392 | |||
393 |
|
393 | |||
394 |
|
394 | |||
395 |
|
395 | |||
396 | History |
|
396 | History | |
397 | ======================================================= |
|
397 | ======================================================= | |
398 |
|
398 | |||
399 | See `HISTORY.rst`_. |
|
399 | See `HISTORY.rst`_. | |
400 |
|
400 | |||
401 | Repository, bug reports, enhancement suggestions |
|
401 | Repository, bug reports, enhancement suggestions | |
402 | =================================================== |
|
402 | =================================================== | |
403 |
|
403 | |||
404 | Development is tracked on HeptaPod, see |
|
404 | Development is tracked on HeptaPod, see | |
405 | https://foss.heptapod.net/mercurial/mercurial_keyring/ |
|
405 | https://foss.heptapod.net/mercurial/mercurial_keyring/ | |
406 |
|
406 | |||
407 | Use issue tracker there for bug reports and enhancement |
|
407 | Use issue tracker there for bug reports and enhancement | |
408 | suggestions. |
|
408 | suggestions. | |
409 |
|
409 | |||
410 | Thanks to Octobus_ and `Clever Cloud`_ for hosting this service. |
|
410 | Thanks to Octobus_ and `Clever Cloud`_ for hosting this service. | |
411 |
|
411 | |||
412 |
|
412 | |||
413 |
|
413 | |||
414 | Additional notes |
|
414 | Additional notes | |
415 | ======================================================= |
|
415 | ======================================================= | |
416 |
|
416 | |||
417 | Information about this extension is also available |
|
417 | Information about this extension is also available | |
418 | on Mercurial Wiki: http://mercurial.selenic.com/wiki/KeyringExtension |
|
418 | on Mercurial Wiki: http://mercurial.selenic.com/wiki/KeyringExtension | |
419 |
|
419 | |||
420 | Check also `other Mercurial extensions I wrote`_. |
|
420 | Check also `other Mercurial extensions I wrote`_. | |
421 |
|
421 | |||
422 | .. _Octobus: https://octobus.net/ |
|
422 | .. _Octobus: https://octobus.net/ | |
423 | .. _Clever Cloud: https://www.clever-cloud.com/ |
|
423 | .. _Clever Cloud: https://www.clever-cloud.com/ | |
424 |
|
424 | |||
425 |
.. _other Mercurial extensions I wrote: http:// |
|
425 | .. _other Mercurial extensions I wrote: http://code.mekk.waw.pl/mercurial.html | |
426 |
|
426 | |||
427 | .. _HISTORY.rst: https://foss.heptapod.net/mercurial/mercurial_keyring/src/tip/HISTORY.rst |
|
427 | .. _HISTORY.rst: https://foss.heptapod.net/mercurial/mercurial_keyring/src/tip/HISTORY.rst | |
428 | .. _TortoiseHg: http://tortoisehg.bitbucket.org/ |
|
428 | .. _TortoiseHg: http://tortoisehg.bitbucket.org/ | |
429 | .. _Mercurial: http://mercurial.selenic.com |
|
429 | .. _Mercurial: http://mercurial.selenic.com | |
430 | .. _mercurial_extension_utils: https://foss.heptapod.net/mercurial/mercurial-extension_utils/ |
|
430 | .. _mercurial_extension_utils: https://foss.heptapod.net/mercurial/mercurial-extension_utils/ | |
431 | .. _Path Pattern: https://foss.heptapod.net/mercurial/mercurial-path_pattern/ |
|
431 | .. _Path Pattern: https://foss.heptapod.net/mercurial/mercurial-path_pattern/ |
General Comments 0
You need to be logged in to leave comments.
Login now