Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

authentication with python program

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


yourpadre at gmail

Apr 17, 2008, 1:39 PM

Post #1 of 9 (693 views)
Permalink
authentication with python program

I have this program what open a dtml what return a XML page, but I
have error with permisions:

import urllib, urllib2

pagina = "http://10.28.1.239/bitacoras/alta/estado2.html"
datos = {"btipo":"D",
"bholo":87654321,
"bplac":"dd-12345",
"accion":"alta_gasolina",
}

params=urllib.urlencode(datos)
aut=urllib2.HTTPBasicAuthHandler()
aut.add_password("AFICON", pagina, "myuser", "mypass")
opener=urllib2.build_opener(aut)
urllib2.install_opener(opener)
r=urllib2.urlopen(pagina,params)
print r.read()
r.close()

but returned XML say:
<ajax>
<accion>alta_gasolina</accion>
<respuesta>error</respuesta>
<error_type>Unauthorized</error_type>
<error_description>You are not allowed to access 'zsql_alta'
in this context</error_description>

</ajax>

help? how I can send HTTPBasicAuth?

pd. Sorry by my bad english
--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


jmeile at hotmail

Apr 18, 2008, 12:21 AM

Post #2 of 9 (671 views)
Permalink
Re: authentication with python program [In reply to]

Hi Miguel

First, you could drop the Unauthorized Exception from the error_log
object in the root folder of the zope management interface. Then
activate the verbose-security option in your zope.conf file. To do
this, you need to put/replace this lines:

security-policy-implementation python
verbose-security on

After you have done this, you need to restart zope, try again your
authentication script, and take a look at your event.log file or
the error_log object. You may find the reason of why is this failing.
In case you don't find it, then place the full traceback here.

Best regards
Josef

Miguel Beltran R. schrieb:
> I have this program what open a dtml what return a XML page, but I
> have error with permisions:
>
> import urllib, urllib2
>
> pagina = "http://10.28.1.239/bitacoras/alta/estado2.html"
> datos = {"btipo":"D",
> "bholo":87654321,
> "bplac":"dd-12345",
> "accion":"alta_gasolina",
> }
>
> params=urllib.urlencode(datos)
> aut=urllib2.HTTPBasicAuthHandler()
> aut.add_password("AFICON", pagina, "myuser", "mypass")
> opener=urllib2.build_opener(aut)
> urllib2.install_opener(opener)
> r=urllib2.urlopen(pagina,params)
> print r.read()
> r.close()
>
> but returned XML say:
> <ajax>
> <accion>alta_gasolina</accion>
> <respuesta>error</respuesta>
> <error_type>Unauthorized</error_type>
> <error_description>You are not allowed to access 'zsql_alta'
> in this context</error_description>
>
> </ajax>
>
> help? how I can send HTTPBasicAuth?
>
> pd. Sorry by my bad english

_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


martijn at fourdigits

Apr 18, 2008, 12:42 AM

Post #3 of 9 (672 views)
Permalink
Re: Re: authentication with python program [In reply to]

Hi Miguel,

Is the dtml page accessable by the role "myuser" has? Did you set the
"Use Database Methods" permission for that role?




> Hi Miguel
>
> First, you could drop the Unauthorized Exception from the error_log
> object in the root folder of the zope management interface. Then
> activate the verbose-security option in your zope.conf file. To do
> this, you need to put/replace this lines:
>
> security-policy-implementation python
> verbose-security on
>
> After you have done this, you need to restart zope, try again your
> authentication script, and take a look at your event.log file or
> the error_log object. You may find the reason of why is this failing.
> In case you don't find it, then place the full traceback here.
>
> Best regards
> Josef
>
> Miguel Beltran R. schrieb:
>> I have this program what open a dtml what return a XML page, but I
>> have error with permisions:
>>
>> import urllib, urllib2
>>
>> pagina = "http://10.28.1.239/bitacoras/alta/estado2.html"
>> datos = {"btipo":"D",
>> "bholo":87654321,
>> "bplac":"dd-12345",
>> "accion":"alta_gasolina",
>> }
>>
>> params=urllib.urlencode(datos)
>> aut=urllib2.HTTPBasicAuthHandler()
>> aut.add_password("AFICON", pagina, "myuser", "mypass")
>> opener=urllib2.build_opener(aut)
>> urllib2.install_opener(opener)
>> r=urllib2.urlopen(pagina,params)
>> print r.read()
>> r.close()
>>
>> but returned XML say:
>> <ajax>
>> <accion>alta_gasolina</accion>
>> <respuesta>error</respuesta>
>> <error_type>Unauthorized</error_type>
>> <error_description>You are not allowed to access 'zsql_alta'
>> in this context</error_description>
>>
>> </ajax>
>>
>> help? how I can send HTTPBasicAuth?
>>
>> pd. Sorry by my bad english
>
> _______________________________________________
> Zope maillist - Zope[at]zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )


--
Martijn Jacobs
Four Digits, Internet Solutions

a: Willemsplein 15-1 6811 KB Arnhem NL
kvk: 091621370000 | btw: 8161.22.234.B01
e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117

_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


yourpadre at gmail

Apr 18, 2008, 8:10 AM

Post #4 of 9 (663 views)
Permalink
Re: Re: authentication with python program [In reply to]

#Martijn
Yes, have role manager

#Josef
After change options and restart
----Z2.log:
10.28.1.18 - admin [18/Apr/2008:17:01:08 +0200] "GET
/Control_Panel/manage_main HTTP/1.1" 200 8023 "" "Mozilla/5.0
(Windows; U; Windows NT 5.1; es-AR; rv:1.8.1.14) Gecko/20080404
Firefox/2.0.0.14"
10.28.1.18 - Anonymous [18/Apr/2008:17:01:18 +0200] "POST
/bitacoras/alta/estado2.html HTTP/1.1" 200 692 "" "Python-urllib/2.5"

----trace.log:
B 36356824 2008-04-18T17:01:08 GET /Control_Panel/manage_main
I 36356824 2008-04-18T17:01:08 0
A 36356824 2008-04-18T17:01:08 200 8023
E 36356824 2008-04-18T17:01:08
B 36356864 2008-04-18T17:01:18 POST /bitacoras/alta/estado2.html
I 36356864 2008-04-18T17:01:18 434
A 36356864 2008-04-18T17:01:18 200 692
E 36356864 2008-04-18T17:01:18

----error_log:
<nothing>??



2008/4/18, Josef Meile <jmeile[at]hotmail.com>:
> Hi Miguel
>
> First, you could drop the Unauthorized Exception from the error_log
> object in the root folder of the zope management interface. Then
> activate the verbose-security option in your zope.conf file. To do
> this, you need to put/replace this lines:
>
> security-policy-implementation python
> verbose-security on
>
> After you have done this, you need to restart zope, try again your
> authentication script, and take a look at your event.log file or
> the error_log object. You may find the reason of why is this failing.
> In case you don't find it, then place the full traceback here.
>
> Best regards
> Josef
>
> Miguel Beltran R. schrieb:
>
>
> > I have this program what open a dtml what return a XML page, but I
> > have error with permisions:
> >
> > import urllib, urllib2
> >
> > pagina = "http://10.28.1.239/bitacoras/alta/estado2.html"
> > datos = {"btipo":"D",
> > "bholo":87654321,
> > "bplac":"dd-12345",
> > "accion":"alta_gasolina",
> > }
> >
> > params=urllib.urlencode(datos)
> > aut=urllib2.HTTPBasicAuthHandler()
> > aut.add_password("AFICON", pagina, "myuser", "mypass")
> > opener=urllib2.build_opener(aut)
> > urllib2.install_opener(opener)
> > r=urllib2.urlopen(pagina,params)
> > print r.read()
> > r.close()
> >
> > but returned XML say:
> > <ajax>
> > <accion>alta_gasolina</accion>
> > <respuesta>error</respuesta>
> > <error_type>Unauthorized</error_type>
> > <error_description>You are not allowed to access 'zsql_alta'
> > in this context</error_description>
> >
> > </ajax>
> >
> > help? how I can send HTTPBasicAuth?
> >
> > pd. Sorry by my bad english
> >
>
> _______________________________________________
> Zope maillist - Zope[at]zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>


--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


martijn at fourdigits

Apr 18, 2008, 9:03 AM

Post #5 of 9 (663 views)
Permalink
Re: Re: authentication with python program [In reply to]

Miguel Beltran R. wrote:
> #Martijn
> Yes, have role manager
>
>
>
What if you login with the user with your webbrowser instead of your
python program?


--
Martijn Jacobs
Four Digits, Internet Solutions

a: Willemsplein 15-1 6811 KB Arnhem NL
kvk: 091621370000 | btw: 8161.22.234.B01
e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117

_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


yourpadre at gmail

Apr 18, 2008, 10:37 AM

Post #6 of 9 (657 views)
Permalink
Re: Re: authentication with python program [In reply to]

Using web browser work fine.

Using wireshark I see what my python program not send WWW-Authentification.

Now I going to python list. But if someone know how can tell me please

2008/4/18, Martijn Jacobs <martijn[at]fourdigits.nl>:
> Miguel Beltran R. wrote:
>
> > #Martijn
> > Yes, have role manager
> >
> >
> >
> >
> What if you login with the user with your webbrowser instead of your python
> program?
>
>
> --
> Martijn Jacobs
> Four Digits, Internet Solutions
>
> a: Willemsplein 15-1 6811 KB Arnhem NL kvk: 091621370000 | btw:
> 8161.22.234.B01
> e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
> tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117
>


--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


martijn at fourdigits

Apr 18, 2008, 11:08 AM

Post #7 of 9 (660 views)
Permalink
Re: Re: authentication with python program [In reply to]

I have a very old python script which does want you want, I can send it
to you if you like.


Martijn
> Using web browser work fine.
>
> Using wireshark I see what my python program not send WWW-Authentification.
>
> Now I going to python list. But if someone know how can tell me please
>
> 2008/4/18, Martijn Jacobs <martijn[at]fourdigits.nl>:
>
>> Miguel Beltran R. wrote:
>>
>>
>>> #Martijn
>>> Yes, have role manager
>>>
>>>
>>>
>>>
>>>
>> What if you login with the user with your webbrowser instead of your python
>> program?
>>
>>
>> --
>> Martijn Jacobs
>> Four Digits, Internet Solutions
>>
>> a: Willemsplein 15-1 6811 KB Arnhem NL kvk: 091621370000 | btw:
>> 8161.22.234.B01
>> e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
>> tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117
>>
>>
>
>
>


--
Martijn Jacobs
Four Digits, Internet Solutions

a: Willemsplein 15-1 6811 KB Arnhem NL
kvk: 091621370000 | btw: 8161.22.234.B01
e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117


yourpadre at gmail

Apr 18, 2008, 1:35 PM

Post #8 of 9 (652 views)
Permalink
Re: Re: authentication with python program [In reply to]

Yes please
and thakns to every body

2008/4/18, Martijn Jacobs <martijn[at]fourdigits.nl>:
>
> I have a very old python script which does want you want, I can send it to
> you if you like.
>
>
> Martijn
>
> Using web browser work fine.
>
> Using wireshark I see what my python program not send WWW-Authentification.
>
> Now I going to python list. But if someone know how can tell me please
>
> 2008/4/18, Martijn Jacobs <martijn[at]fourdigits.nl>:
>
>
> Miguel Beltran R. wrote:
>
>
>
> #Martijn
> Yes, have role manager
>
>
>
>
>
> What if you login with the user with your webbrowser instead of your python
> program?
>
>
> --
> Martijn Jacobs
> Four Digits, Internet Solutions
>
> a: Willemsplein 15-1 6811 KB Arnhem NL kvk: 091621370000 | btw:
> 8161.22.234.B01
> e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
> tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117
>
>
>
>
>
>
> --
> Martijn Jacobs
> Four Digits, Internet Solutions
>
> a: Willemsplein 15-1 6811 KB Arnhem NL
> kvk: 091621370000 | btw: 8161.22.234.B01
> e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
> tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117
>
>


--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


martijn at fourdigits

Apr 18, 2008, 3:48 PM

Post #9 of 9 (652 views)
Permalink
Re: Re: authentication with python program [In reply to]

Miguel Beltran R. wrote:
> Yes please
> and thakns to every body
>
Here you go :

#!/bin/python

import base64
import urllib2
base64string = base64.encodestring('%s:%s' % ("username", "password"))
url = "http://10.28.1.239/bitacoras/alta/estado2.html"
req = urllib2.Request(url)
req.add_header("Authorization", "Basic %s" % base64string)
handle = urllib2.urlopen(req)
print handle.read()




--
Martijn Jacobs
Four Digits, Internet Solutions

a: Willemsplein 15-1 6811 KB Arnhem NL
kvk: 091621370000 | btw: 8161.22.234.B01
e-mail: martijn[at]fourdigits.nl | web: http://www.fourdigits.nl
tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117

_______________________________________________
Zope maillist - Zope[at]zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Zope users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.