kragniz / kragniz/python-etcd3
Authentication with username and password doesn't work?
- Dominant language
- Python
- Stars
- 450
- Forks
- 194
- PR merge metrics
- No merged PRs in 30d
Description
@kragniz , after installed etcd3 version 0.7.0, I can't access data in `etcd` when user authentication is enabled. The following is the traceback,
```
In [30]: Etcd3Client(user='root', password='xxxxxx')
Out[30]:
In [31]: Out[30].get('foo')
---------------------------------------------------------------------------
_Rendezvous Traceback (most recent call last)
in ()
----> 1 Out[30].get('foo')
/Users/justdoit/workspace/works/laiye/venv/v3.6/lib/python3.6/site-packages/etcd3/client.py in handler(*args, **kwargs)
46 return f(*args, **kwargs)
47 except grpc.RpcError as exc:
---> 48 _translate_exception(exc)
49
50 return functools.wraps(f)(handler)
/Users/justdoit/workspace/works/laiye/venv/v3.6/lib/python3.6/site-packages/etcd3/client.py in handler(*args, **kwargs)
44 def handler(*args, **kwargs):
45 try:
---> 46 return f(*args, **kwargs)
47 except grpc.RpcError as exc:
48 _translate_exception(exc)
/Users/justdoit/workspace/works/laiye/venv/v3.6/lib/python3.6/site-packages/etcd3/client.py in get(self, key)
247 range_request,
248 self.timeout,
--> 249 credentials=self.call_credentials,
250 )
251
/Users/justdoit/workspace/works/laiye/venv/v3.6/lib/python3.6/site-packages/grpc/_channel.py in __call__(self, request, timeout, metadata, credentials)
490 state, call, deadline = self._blocking(request, timeout, metadata,
491 credentials)
--> 492 return _end_unary_response_blocking(state, call, False, deadline)
493
494 def with_call(self, request, timeout=None, metadata=None, credentials=None):
/Users/justdoit/workspace/works/laiye/venv/v3.6/lib/python3.6/site-packages/grpc/_channel.py in _end_unary_response_blocking(state, call, with_call, deadline)
438 return state.response
439 else:
--> 440 raise _Rendezvous(state, None, None, deadline)
441
442
_Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, etcdserver: user name is empty)>
```
This was tested on my Mac, with python version 3.6, and detailed as the followed,
```
Python 3.6.0 (default, Mar 24 2017, 18:00:20)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
```
The Mac version is `Darwin yusenbindeMacBook-Pro.local 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64`.
However, I could access with `etcdctl` command line tool,
```
yusenbindeMacBook-Pro:etcd justdoit$ export ETCDCTL_API=3
yusenbindeMacBook-Pro:etcd justdoit$ etcdctl --user=root get foo
Password:
foo
bar_1
```
The authentication process had already succeeded, and the message was logged.
>2017-11-13 17:06:16.295082 D | auth: authorized root, token is dAhzbXDmVRQsFJYA.72`
It's the same as what `etcdctl` has did. Hence it seems that the gRPC's call credential check has failed.
So, guys, how does this occurred?
Contributor guide
Research direction
Start in etcd3/client.py around Etcd3Client, get(), and call_credentials, then compare the Python client's authenticated request with the working etcdctl --user=root command. Reproduce the reported INVALID_ARGUMENT error and verify that an authenticated get('foo') succeeds without the empty-user message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, python
- Domain
- api, authentication, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100