Python client and BaseX 8.0
Monday, 29 December 2014 · 10 messages · last reply 6 Jan 2015
MG
Marc van Grootel29 Dec 2014 14:40 #
Hi,
Anyone using the python client. I used it before, I think it was with 7.9, where it was still working. But now on a recent snapshot I cannot get my example to work anymore. I will report to maintainer but I would like to know if anyone could confirm having difficulties too.
Anything changed in the protocol?
I'm running on Python 2.7.8 :: Anaconda 2.0.1 (x86_64), on Mac that is.
The error message occurs when trying to set up a session:
/Users/marcvangrootel/Dropbox/notebooks/BaseXClient.py in __init__(self, host, port, user, password, receive_bytes_encoding, send_bytes_encoding)
129 # evaluate success flag
130 if not self.server_response_success():
--> 131 raise IOError('Access Denied.')
132
133 def execute(self, com):
IOError: Access Denied.
Thanks,
--Marc
AJ
Andreas Jung29 Dec 2014 14:45 #
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
<offtopic>I am working with Python and Base-X for a while but not through the standard Python bindings. Instead I am using the "pyfilesystem" module for Python for accessing Base-X content through the WebDAV port using standard file operation methods as you know it from Python. </offtopic>
Andreas
Quoted text · Marc van Grootel · 26 lines
Marc van Grootel wrote: > Hi, > > Anyone using the python client. I used it before, I think it was > with 7.9, where it was still working. But now on a recent snapshot I > cannot get my example to work anymore. I will report to maintainer > but I would like to know if anyone could confirm having difficulties > too. > > Anything changed in the protocol? > > I'm running on Python 2.7.8 :: Anaconda 2.0.1 (x86_64), on Mac that > is. > > The error message occurs when trying to set up a session: > > /Users/marcvangrootel/Dropbox/notebooks/BaseXClient.py in > __init__(self, host, port, user, password, receive_bytes_encoding, > send_bytes_encoding) 129 # evaluate success flag 130 > if not self.server_response_success(): --> 131 raise > IOError('Access Denied.') 132 133 def execute(self, com): > > IOError: Access Denied. > > > Thanks, --Marc
- --
Regards
Andreas Jung
andreas at andreas-jung.com
about.me/andreasjung
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJUoVsUAAoJEADcfz7u4AZjWoILwMUkypGYOB8N9NPenIXNCZaD iQLCLDpVMr7RuTTj9M8E5yfOx22fgVdU9kcfPI5s13RHlH7UVYabkIypxQXsjUmJ Shb4TPdYO44cP1fqC43vcNu9yODBCq/hnugPK4VnsN0V/UBRIA2ghEQEYWB4Gygc b5XJt7kFOgZDLLV3JYfaSv8y3SH5HsHPSYqy7thKncOhK9K7tzuDqhyPmWAXt3a+ 8emragz+PnVLrY2/mirC5sk8a0FnpW1nJ9/eqvnhqxtmBpD6IQurG3v8xXZ5YRaf BBcHaSqxspntjUSLqtXp4bdHcJT/+YNZMyD+lEetYzTuBIGnyHXpGTtD1Fkru2Bf yGj0Yp/kTng0QrFZpwU28TUboEKyy+Xkav69julzTIIKk8ocZCkQsWAlFD/QWSws WJj/+ScEDWNk5d5KugkwfFbDv8LIM78Sz2odzGAvoh7t9/66hP0kiPtuGXcLqsXY wAE7hoIAdIPut52m+0R2N2AyBgZ/9Fc=
=xR76
-----END PGP SIGNATURE-----
DK
Hello Marc,
indeed, there has been changes regarding the authentication in our client/server protocol as outlined by Christian in this mail: https://mailman.uni-konstanz.de/pipermail/basex-talk/2014-December/007832.html. There is also some short documentation to be found here:
http://docs.basex.org/wiki/Server_Protocol
Hence, the client bindings have to be changed accordingly. It should be a fairly trivial change. If anyone wants to submit a short patch for the python clients (or others clients we support), I am sure it would be appreciated.
Cheers,
Dirk
Quoted text · Marc van Grootel · 29 lines
On 12/29/2014 02:40 PM, Marc van Grootel wrote: > Hi, > > Anyone using the python client. I used it before, I think it was with > 7.9, where it was still working. But now on a recent snapshot I cannot > get my example to work anymore. I will report to maintainer but I > would like to know if anyone could confirm having difficulties too. > > Anything changed in the protocol? > > I'm running on Python 2.7.8 :: Anaconda 2.0.1 (x86_64), on Mac that is. > > The error message occurs when trying to set up a session: > > /Users/marcvangrootel/Dropbox/notebooks/BaseXClient.py in > __init__(self, host, port, user, password, receive_bytes_encoding, > send_bytes_encoding) > 129 # evaluate success flag > 130 if not self.server_response_success(): > --> 131 raise IOError('Access Denied.') > 132 > 133 def execute(self, com): > > IOError: Access Denied. > > > Thanks, > --Marc >
--
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
MG
Hi Andreas,
Maybe that is a better way but I am using the client from within a IPython Notebook which means I can integrate a bit more closely with the notebook interface and do queries and graphing with the data using IPythons great analytics and graphing features..
I had this working with 7.9.
--Marc
Quoted text · Andreas Jung · 62 lines
On Mon, Dec 29, 2014 at 2:45 PM, Andreas Jung <lists at zopyx.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > <offtopic> > > I am working with Python and Base-X for a while but not through > the standard Python bindings. Instead I am using the "pyfilesystem" > module for Python for accessing Base-X content through the WebDAV > port using standard file operation methods as you know it from Python. > </offtopic> > > Andreas > > Marc van Grootel wrote: >> Hi, >> >> Anyone using the python client. I used it before, I think it was >> with 7.9, where it was still working. But now on a recent snapshot I >> cannot get my example to work anymore. I will report to maintainer >> but I would like to know if anyone could confirm having difficulties >> too. >> >> Anything changed in the protocol? >> >> I'm running on Python 2.7.8 :: Anaconda 2.0.1 (x86_64), on Mac that >> is. >> >> The error message occurs when trying to set up a session: >> >> /Users/marcvangrootel/Dropbox/notebooks/BaseXClient.py in >> __init__(self, host, port, user, password, receive_bytes_encoding, >> send_bytes_encoding) 129 # evaluate success flag 130 >> if not self.server_response_success(): --> 131 raise >> IOError('Access Denied.') 132 133 def execute(self, com): >> >> IOError: Access Denied. >> >> >> Thanks, --Marc > > > - -- > Regards > Andreas Jung > andreas at andreas-jung.com > about.me/andreasjung > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.11 (Darwin) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iQGUBAEBAgAGBQJUoVsUAAoJEADcfz7u4AZjWoILwMUkypGYOB8N9NPenIXNCZaD > iQLCLDpVMr7RuTTj9M8E5yfOx22fgVdU9kcfPI5s13RHlH7UVYabkIypxQXsjUmJ > Shb4TPdYO44cP1fqC43vcNu9yODBCq/hnugPK4VnsN0V/UBRIA2ghEQEYWB4Gygc > b5XJt7kFOgZDLLV3JYfaSv8y3SH5HsHPSYqy7thKncOhK9K7tzuDqhyPmWAXt3a+ > 8emragz+PnVLrY2/mirC5sk8a0FnpW1nJ9/eqvnhqxtmBpD6IQurG3v8xXZ5YRaf > BBcHaSqxspntjUSLqtXp4bdHcJT/+YNZMyD+lEetYzTuBIGnyHXpGTtD1Fkru2Bf > yGj0Yp/kTng0QrFZpwU28TUboEKyy+Xkav69julzTIIKk8ocZCkQsWAlFD/QWSws > WJj/+ScEDWNk5d5KugkwfFbDv8LIM78Sz2odzGAvoh7t9/66hP0kiPtuGXcLqsXY > wAE7hoIAdIPut52m+0R2N2AyBgZ/9Fc= > =xR76 > -----END PGP SIGNATURE-----
--
--Marc
MG
Marc van Grootel29 Dec 2014 16:57 #
Hi Dirk,
I fooled around with the client a bit but I am not familiar enough with the crypto stuff. As Christian mentioned it might be trivial I took a stab at it.
However I am a bit stumped on the use of sha256 vs. md5, the docs [1] mentions:
{md5(md5(username:realm:password) + nonce)}
but Christian's mail mentioned salted sha256. How's one related to the other?
Second issue I have is regarding the salt. Where do I put it and do I then have to add it to all server communication or only to the authentication/getting a session?
I could take another stab but I guess I need a little bit of guidance.
Sorry if I sound like a noob on this crypto stuff ;-)
[1]: http://docs.basex.org/wiki/Server_Protocol#Authentication
Quoted text · Marc van Grootel · 80 lines
On Mon, Dec 29, 2014 at 2:54 PM, Marc van Grootel <marc.van.grootel at gmail.com> wrote: > Hi Andreas, > > Maybe that is a better way but I am using the client from within a > IPython Notebook which means I can integrate a bit more closely with > the notebook interface and do queries and graphing with the data using > IPythons great analytics and graphing features.. > > I had this working with 7.9. > > --Marc > > On Mon, Dec 29, 2014 at 2:45 PM, Andreas Jung <lists at zopyx.com> wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> <offtopic> >> >> I am working with Python and Base-X for a while but not through >> the standard Python bindings. Instead I am using the "pyfilesystem" >> module for Python for accessing Base-X content through the WebDAV >> port using standard file operation methods as you know it from Python. >> </offtopic> >> >> Andreas >> >> Marc van Grootel wrote: >>> Hi, >>> >>> Anyone using the python client. I used it before, I think it was >>> with 7.9, where it was still working. But now on a recent snapshot I >>> cannot get my example to work anymore. I will report to maintainer >>> but I would like to know if anyone could confirm having difficulties >>> too. >>> >>> Anything changed in the protocol? >>> >>> I'm running on Python 2.7.8 :: Anaconda 2.0.1 (x86_64), on Mac that >>> is. >>> >>> The error message occurs when trying to set up a session: >>> >>> /Users/marcvangrootel/Dropbox/notebooks/BaseXClient.py in >>> __init__(self, host, port, user, password, receive_bytes_encoding, >>> send_bytes_encoding) 129 # evaluate success flag 130 >>> if not self.server_response_success(): --> 131 raise >>> IOError('Access Denied.') 132 133 def execute(self, com): >>> >>> IOError: Access Denied. >>> >>> >>> Thanks, --Marc >> >> >> - -- >> Regards >> Andreas Jung >> andreas at andreas-jung.com >> about.me/andreasjung >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.11 (Darwin) >> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ >> >> iQGUBAEBAgAGBQJUoVsUAAoJEADcfz7u4AZjWoILwMUkypGYOB8N9NPenIXNCZaD >> iQLCLDpVMr7RuTTj9M8E5yfOx22fgVdU9kcfPI5s13RHlH7UVYabkIypxQXsjUmJ >> Shb4TPdYO44cP1fqC43vcNu9yODBCq/hnugPK4VnsN0V/UBRIA2ghEQEYWB4Gygc >> b5XJt7kFOgZDLLV3JYfaSv8y3SH5HsHPSYqy7thKncOhK9K7tzuDqhyPmWAXt3a+ >> 8emragz+PnVLrY2/mirC5sk8a0FnpW1nJ9/eqvnhqxtmBpD6IQurG3v8xXZ5YRaf >> BBcHaSqxspntjUSLqtXp4bdHcJT/+YNZMyD+lEetYzTuBIGnyHXpGTtD1Fkru2Bf >> yGj0Yp/kTng0QrFZpwU28TUboEKyy+Xkav69julzTIIKk8ocZCkQsWAlFD/QWSws >> WJj/+ScEDWNk5d5KugkwfFbDv8LIM78Sz2odzGAvoh7t9/66hP0kiPtuGXcLqsXY >> wAE7hoIAdIPut52m+0R2N2AyBgZ/9Fc= >> =xR76 >> -----END PGP SIGNATURE----- > > > > -- > --Marc
--
--Marc
MG
Marc van Grootel29 Dec 2014 16:57 #
... or maybe there's some client code that is already updated, then I could take a look at that.
--Marc
MG
Marc van Grootel29 Dec 2014 17:05 #
ah, of course, I can always take a look at
https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/api/BaseXClient.java
I'll have another go at it then.
--Marc
Quoted text · Marc van Grootel · 5 lines
On Mon, Dec 29, 2014 at 4:57 PM, Marc van Grootel <marc.van.grootel at gmail.com> wrote: > ... or maybe there's some client code that is already updated, then I > could take a look at that. > --Marc
--
--Marc
MG
Marc van Grootel29 Dec 2014 17:12 #
Yesss. I think I have it. The salt and sha256 bit threw me off a bit but after a look at the java code it was indeed trivial.
I do some more testing with it and also make it work with 7.x and then I submit it to the maintainer.
Thanks for playing rubber duck.
--Marc
Quoted text · Marc van Grootel · 19 lines
On Mon, Dec 29, 2014 at 5:05 PM, Marc van Grootel <marc.van.grootel at gmail.com> wrote: > ah, of course, I can always take a look at > https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/api/BaseXClient.java > > I'll have another go at it then. > > --Marc > > On Mon, Dec 29, 2014 at 4:57 PM, Marc van Grootel > <marc.van.grootel at gmail.com> wrote: >> ... or maybe there's some client code that is already updated, then I >> could take a look at that. >> --Marc > > > > -- > --Marc
--
--Marc
MG
Marc van Grootel29 Dec 2014 17:35 #
Hi,
Seems to work fine. At least, I didn't introduce any issues that weren't already there. I didn't find the email address of the maintainer I attach the file to this post. I have checked on recent snapshot of 8.0 and 7.9.
If you want me to submit it differently or have me create a pull request let me know.
Here's the diff
120c120
< timestamp = self.recv_c_str()
Quoted text · Marc van Grootel · 2 lines
--- > response = self.recv_c_str().split(':')
124,126c124,133
< #FIXME: should we allow to customize password encoding? < hfun.update(hashlib.md5(password.encode('us-ascii')).hexdigest().encode('us-ascii')) < hfun.update(timestamp.encode('us-ascii'))
---
Quoted text · Marc van Grootel · 10 lines
> > if len(response) > 1: > code = "%s:%s:%s" % (user,response[0],password) > nonce = response[1] > else: > code = password > nonce = response[0] > > hfun.update(hashlib.md5(code.encode('us-ascii')).hexdigest().encode('us-ascii')) > hfun.update(nonce.encode('us-ascii'))
374c381
< return result
\ No newline at end of file
Quoted text · Marc van Grootel · 2 lines
--- > return result
CG
Christian Grün6 Jan 2015 10:08 #
Thanks Marc,
I have patched the python code, it should now be compatible with BaseX 8.0.
Christian
Quoted text · Marc van Grootel · 38 lines
On Mon, Dec 29, 2014 at 5:35 PM, Marc van Grootel <marc.van.grootel at gmail.com> wrote: > Hi, > > Seems to work fine. At least, I didn't introduce any issues that > weren't already there. I didn't find the email address of the > maintainer I attach the file to this post. I have checked on recent > snapshot of 8.0 and 7.9. > > If you want me to submit it differently or have me create a pull > request let me know. > > Here's the diff > > 120c120 > < timestamp = self.recv_c_str() > --- >> response = self.recv_c_str().split(':') > 124,126c124,133 > < #FIXME: should we allow to customize password encoding? > < hfun.update(hashlib.md5(password.encode('us-ascii')).hexdigest().encode('us-ascii')) > < hfun.update(timestamp.encode('us-ascii')) > --- >> >> if len(response) > 1: >> code = "%s:%s:%s" % (user,response[0],password) >> nonce = response[1] >> else: >> code = password >> nonce = response[0] >> >> hfun.update(hashlib.md5(code.encode('us-ascii')).hexdigest().encode('us-ascii')) >> hfun.update(nonce.encode('us-ascii')) > 374c381 > < return result > \ No newline at end of file > --- >> return result
Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery