Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database user credentials not enough to access database #32

Closed
DeividasJackus opened this issue Dec 23, 2014 · 4 comments
Closed

Database user credentials not enough to access database #32

DeividasJackus opened this issue Dec 23, 2014 · 4 comments
Assignees
Labels

Comments

@DeividasJackus
Copy link

The driver does not allow to open a database without connecting to the server instance using server credentials first.

In other words, ODB console allows to use credentials set as the OUser documents in the DB without using the credentials defined in `orientdb-server-config.xml':

orientdb> connect remote:localhost/test admin admin
Connecting to database [remote:localhost/test] with user 'admin'...OK

pyorient, on the other hand, does not allow to do so without caling OrientDB.connect() first:

>>> import pyorient ; client = pyorient.OrientDB("localhost", 2424) ; client.db_open("test", "admin", "admin")
...
pyorient.exceptions.PyOrientCommandException: b'Wrong user/password to [connect] to the remote OrientDB Server instance. Get the user/password from the config/orientdb-server-config.xml file - com.orientechnologies.orient.core.exception.OSecurityAccessException'
@Ostico
Copy link
Collaborator

Ostico commented Dec 23, 2014

Sorry sinfex but this is not true, this functionality exists since the first version.

client = pyorient.OrientDB("localhost", 2424)
cluster_info = client.db_open(
    'GratefulDeadConcerts', "admin", "admin"
)
print(cluster_info)
[{'name': b'e', 'id': 10}, {'name': b'index', 'id': 1}, {'name': b'orole', 'id': 4}, {'name': b'v', 'id': 9}, {'name': b'ofunction', 'id': 7}, {'name': b'default', 'id': 3}, {'name': b'manindex', 'id': 2}, {'name': b'orids', 'id': 6}, {'name': b'ouser', 'id': 5}, {'name': b'internal', 'id': 0}, {'name': b'followed_by', 'id': 11}, {'name': b'oschedule', 'id': 8}]

@Ostico Ostico closed this as completed Dec 23, 2014
@Ostico Ostico reopened this Dec 23, 2014
@Ostico Ostico closed this as completed Dec 23, 2014
@DeividasJackus
Copy link
Author

I am sorry, but that does not seem to be true. I have tested it several times with python-3.4.1, orientdb-2.0-m3 and a recently forked version of pyorient. I have just tested it out again just in case, using a different server with a fresh installation of python 2.7.5, orientdb 1.7.10 and pyorient 1.2.1, the result is the same.

[dave@studs bin]$ sudo pip install pyorient
Downloading/unpacking pyorient
  Downloading pyorient-1.2.1.tar.gz (47kB): 47kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pyorient/setup.py) egg_info for package pyorient

Installing collected packages: pyorient
  Running setup.py install for pyorient

Successfully installed pyorient
Cleaning up...
[dave@studs bin]$ python2
Python 2.7.5 (default, Jun 17 2014, 18:11:42)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyorient
>>> client = pyorient.OrientDB("localhost", 2424)
>>> cluster_info = client.db_open('GratefulDeadConcerts', "admin", "admin")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pyorient/orient.py", line 191, in db_open
    .prepare(args).send().fetch_response()
  File "/usr/lib/python2.7/site-packages/pyorient/messages/database.py", line 91, in prepare
    self._perform_connection()
  File "/usr/lib/python2.7/site-packages/pyorient/messages/database.py", line 63, in _perform_connection
    .prepare( ( self._user, self._pass, self._client_id ) )\
  File "/usr/lib/python2.7/site-packages/pyorient/messages/connection.py", line 54, in fetch_response
    self._session_id = super( ConnectMessage, self ).fetch_response()[0]
  File "/usr/lib/python2.7/site-packages/pyorient/messages/base.py", line 137, in fetch_response
    self._decode_all()
  File "/usr/lib/python2.7/site-packages/pyorient/messages/base.py", line 121, in _decode_all
    self._decode_header()
  File "/usr/lib/python2.7/site-packages/pyorient/messages/base.py", line 109, in _decode_header
    raise PyOrientCommandException(cmd_exc, [])
pyorient.exceptions.PyOrientCommandException: Wrong user/password to [connect] to the remote OrientDB Server instance. Get the user/password from the config/orientdb-server-config.xml file - com.orientechnologies.orient.core.exception.OSecurityAccessException

Would you please double check? The only two explanations I can come up with for your piece of code working for you apart from me encountering an anomaly is either you have admin:admin defined in your orientdb-server-config.xml or you are issuing client.connect("root", "...") before the call to client.db_open.

@Ostico
Copy link
Collaborator

Ostico commented Dec 23, 2014

Yes, you're right, i've two root user, root and admin, you can find my server configuration here:
https://github.com/mogui/pyorient/blob/master/ci/orientdb-server-config.xml#L145.

But this is the right behaviour of the client, the client can't know the root access credentials.

Wrong user/password to [connect] to the remote OrientDB Server instance. 
Get the user/password from the config/orientdb-server-config.xml file - 
com.orientechnologies.orient.core.exception.OSecurityAccessException

This is an exception raised by orientDB.
Moreover, the binary protocol seems not to allow to open a database without a connection because OrientDB raise an exception.

Writing string (4+30=34 bytes): java.lang.NullPointerException [OChannelBinaryServer]

I have to check for this, but i think there is not a solution at the moment.

@Ostico Ostico reopened this Dec 23, 2014
@DeividasJackus
Copy link
Author

I believe that should be possible since console.sh does seem to allow this while using the binary protocol (using "remote" connection mode and not "plocal"):

bash-4.2$ sh console.sh
orientdb> connect remote:localhost/test reader reader    <--- reader:reader from OUser
Connecting to database [remote:localhost/test] with user 'reader'...OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants