[Cubicweb] Python module for Apache : how to use cubicweb.dbapi
Dimitri Papadopoulos Orfanos
dimitri.papadopoulos at cea.fr
Fri Sep 13 16:11:14 CEST 2013
I'm attemting to write an Apache authentication module that would use
the CWusers of a CubicWeb instance.
We had already discussed the following solution:
* bypass CubicWeb,
* directly connect to the PostgreSQL database associated to the CubicWeb
* read the "cw_login" and "cw_upassword" columns of the "cw_cwuser"
* understand the encoding of the "cw_upassword" column (SHA1?),
* compare the password to the contents of the "cw_upassword" column.
Note that essential information such as the encoding of the
"cw_upassword" column is missing.
Anyway, our sysadmins would rather use a different solution:
* use an Apache module written in Python,
* use cubicweb.dbapi to attempt an authentication against CubicWeb.
Can you help me? We believe we should be using dbapi.connect(), but I
have a hard time finding the correct arguments. Here is my code:
cnx = dbapi.connect(database, login='foo', password='bar')
What should the "database" variable look like? I've tried a few values,
here are my findign so far:
1. database = 'instanceid'
Of course I'd rather use a simple ("in memory"?) connection. Are such
connections available only through "cubicweb-ctl shell"? Is there a way
to avoid "cubicweb-ctl shell"?
2. database = 'zmqpickle-tcp://neurospin-cubicweb:8181'
This works but the connection is slow. It also method requires ZMQ
enabled in the CubicWeb instance.
3. database = 'zmqpickle-tcp://127.0.0.1:8181'
The loopback address does not work! Any clues? Is this a Python or a
cubicweb.dbapi bug/feature? I need to address both interfaces:
- the loopback interface is used by scripts running on the server,
- the regular interface is used by scripts running on other machines.
F-91191 Gif-sur-Yvette cedex, France
More information about the Cubicweb