mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Remove keyring support
This commit is contained in:
parent
7583be5826
commit
3a3b6ee7ee
5 changed files with 22 additions and 52 deletions
|
|
@ -9,6 +9,16 @@ Package maintainers and users who have to manually update their installation
|
||||||
may want to subscribe to `GitHub's tag feed
|
may want to subscribe to `GitHub's tag feed
|
||||||
<https://github.com/untitaker/vdirsyncer/tags.atom>`_.
|
<https://github.com/untitaker/vdirsyncer/tags.atom>`_.
|
||||||
|
|
||||||
|
Version 0.8.0
|
||||||
|
=============
|
||||||
|
|
||||||
|
- Keyring support has been removed, which means that ``password.fetch =
|
||||||
|
["keyring", "example.com", "myuser"]`` doesn't work anymore.
|
||||||
|
|
||||||
|
For existing setups: Use ``password.fetch = ["command", "keyring", "get",
|
||||||
|
"example.com", "myuser"]`` instead, which is more generic. See the
|
||||||
|
documentation for details.
|
||||||
|
|
||||||
Version 0.7.5
|
Version 0.7.5
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,38 +38,23 @@ You can fetch the username as well::
|
||||||
|
|
||||||
Or really any kind of parameter in a storage section.
|
Or really any kind of parameter in a storage section.
|
||||||
|
|
||||||
System Keyring
|
Accessing the system keyring
|
||||||
==============
|
----------------------------
|
||||||
|
|
||||||
While the command approach is quite flexible, it is often cumbersome to write a
|
As shown above, you can use the ``command`` strategy to fetch your credentials
|
||||||
script fetching the system keyring.
|
from arbitrary sources. A very common usecase is to fetch your password from
|
||||||
|
the system keyring.
|
||||||
|
|
||||||
Vdirsyncer can do this for you if you have the keyring_ package installed. How
|
The keyring_ Python package contains a command-line utility for fetching
|
||||||
you would obtain this package depends on how you installed vdirsyncer. If you
|
passwords from the OS's password store. Installation::
|
||||||
used pip, you can use the following command to also install keyring::
|
|
||||||
|
|
||||||
pip install vdirsyncer[keyring]
|
pip install keyring
|
||||||
|
|
||||||
Then you can use::
|
Basic usage::
|
||||||
|
|
||||||
[storage foo]
|
|
||||||
type = caldav
|
|
||||||
username = myusername
|
|
||||||
password.fetch = ["keyring", "myservicename", "myusername"]
|
|
||||||
|
|
||||||
|
|
||||||
The password can than be set like this (in a python interpreter)::
|
|
||||||
|
|
||||||
>>> import keyring
|
|
||||||
>>> keyring.set_password("myservicename", "myusername", "password")
|
|
||||||
|
|
||||||
To test if you got it right you can run::
|
|
||||||
|
|
||||||
>>> keyring.get_password("myservicename", "myusername")
|
|
||||||
"password"
|
|
||||||
|
|
||||||
.. _keyring: https://pypi.python.org/pypi/keyring
|
|
||||||
|
|
||||||
|
password.fetch = ["command", "keyring", "get", "example.com", "foouser"]
|
||||||
|
|
||||||
|
.. _keyring: https://github.com/jaraco/keyring/
|
||||||
|
|
||||||
Password Prompt
|
Password Prompt
|
||||||
===============
|
===============
|
||||||
|
|
|
||||||
1
setup.py
1
setup.py
|
|
@ -50,7 +50,6 @@ setup(
|
||||||
'atomicwrites'
|
'atomicwrites'
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
'keyring': ['keyring'],
|
|
||||||
'remotestorage': ['requests-oauthlib']
|
'remotestorage': ['requests-oauthlib']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,6 @@
|
||||||
|
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
class EmptyKeyring(object):
|
|
||||||
def get_password(self, *a, **kw):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def empty_password_storages(monkeypatch):
|
|
||||||
monkeypatch.setattr('vdirsyncer.cli.fetchparams.keyring', EmptyKeyring())
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_password_from_command(tmpdir, runner):
|
def test_get_password_from_command(tmpdir, runner):
|
||||||
runner.write_with_general(dedent('''
|
runner.write_with_general(dedent('''
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,6 @@ SUFFIX = '.fetch'
|
||||||
|
|
||||||
logger = log.get(__name__)
|
logger = log.get(__name__)
|
||||||
|
|
||||||
try:
|
|
||||||
import keyring
|
|
||||||
except ImportError:
|
|
||||||
keyring = None
|
|
||||||
|
|
||||||
|
|
||||||
def expand_fetch_params(config):
|
def expand_fetch_params(config):
|
||||||
config = dict(config)
|
config = dict(config)
|
||||||
|
|
@ -72,12 +67,6 @@ def _fetch_value(opts, key):
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
||||||
def _strategy_keyring(username, host):
|
|
||||||
if not keyring:
|
|
||||||
raise RuntimeError('Keyring package not available.')
|
|
||||||
return keyring.get_password(username, host)
|
|
||||||
|
|
||||||
|
|
||||||
def _strategy_command(*command):
|
def _strategy_command(*command):
|
||||||
import subprocess
|
import subprocess
|
||||||
command = (expand_path(command[0]),) + command[1:]
|
command = (expand_path(command[0]),) + command[1:]
|
||||||
|
|
@ -94,7 +83,6 @@ def _strategy_prompt(text):
|
||||||
|
|
||||||
|
|
||||||
STRATEGIES = {
|
STRATEGIES = {
|
||||||
'keyring': _strategy_keyring,
|
|
||||||
'command': _strategy_command,
|
'command': _strategy_command,
|
||||||
'prompt': _strategy_prompt,
|
'prompt': _strategy_prompt,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue