[Cubicweb] Apache authentication: which CubicWeb API?
julien.cristau at logilab.fr
Mon Oct 7 11:28:06 CEST 2013
On Mon, Oct 7, 2013 at 11:04:21 +0200, Nicolas Chauvat wrote:
> Hello Dimitri,
> On Mon, Oct 07, 2013 at 10:36:36AM +0200, Sylvain Thénault wrote:
> > Is there any problem with the code below ? it sounds good to me, beside that you
> > should close the opened connection before returning.
> > > from mod_python import apache
> > > from cubicweb import dbapi
> > > from cubicweb import AuthenticationError
> > >
> > > def authenhandler(req):
> > > pw = req.get_basic_auth_pw()
> > > user = req.user
> > >
> > > try:
> > > database = 'zmqpickle-tcp://localhost:8181'
> > > dbapi.connect(database, login=user, password=pw)
> > > return apache.OK
> > > except AuthenticationError:
> > > return apache.HTTP_UNAUTHORIZED
> If the above works for you, please blog about it or provide it as a
> changeset that could be integrated to the documentation or added to a
> tools/ directory in cubicweb (unless someone else has a better idea).
You don't need to use pickle for this, an http request to, say, the
login controller, should work just fine.
Julien Cristau <julien.cristau at logilab.fr>
Informatique scientifique & gestion de connaissances
More information about the Cubicweb