I posted in ernst :) 

Bitten Authentication (
http://bitten.edgewall.org/browser/trunk/bitten/slave.py):

def _get_opener(self):
  opener = urllib2.build_opener(urllib2.HTTPErrorProcessor())
  opener.add_handler(HTTPBasicAuthHandler(self.password_mgr))
  opener.add_handler(urllib2.HTTPDigestAuthHandler(self.password_mgr))
  opener.add_handler(urllib2.HTTPCookieProcessor(self.cookiejar))
  return opener

Thanks all!
Jason

On Wednesday, October 3, 2012 4:48:01 PM UTC-6, Jason Miller wrote:
>
> All,
>
> I have need of creating a small python script which would obtain the 
> current build page (bitten) and return a dictionary of status (and I would 
> be happy to relinquish this small code on demand). In order for this to 
> work, I need to authenticate to any Trac resource beyond the main page. I 
> have yet to successfully do so. Using the examples on the following site: 
> http://docs.python.org/howto/urllib2.html works fine when retrieving 
> resources from an LDAP protected location. But not to a Trac resource. 
>
> My Trac/Apache configuration (urllib2 fails):
> ########################
> # WSGI trac_test Trac page here:
> WSGIScriptAlias /trac_test /data/trac/trac_test/htdocs/trac_init.wsgi
> <Directory /data/trac/trac_test/htdocs>
>  Options -Indexes
>  WSGIApplicationGroup %{GLOBAL}
>  Options FollowSymLinks
>  AllowOverride None
>  Order deny,allow
>  Allow from all
> </Directory>
> <Location '/trac_test/login'>
>   AuthType Basic
>   AuthName "Trac Test Site"
>   AuthBasicProvider ldap
>   AuthLDAPURL "ldap://<someserver>/dc=sub,dc=com?uid"
>   AuthzLDAPAuthoritative off
>   require valid-user
>   Allow from all
> </Location>
> ########################
>
>
>
> An Apache resource configuration (urllib2 succeeds):
> ########################
> <Directory /srv/www/ssl/somelocation>
>  AuthType Basic
>  AuthGroupFile /data/authz_generator/apache_groups
>  AuthName "Doxygen Access"
>  AuthBasicProvider ldap
>  AuthLDAPURL "ldap://<someserver>/dc=sub,dc=com?uid"
>  AuthzLDAPAuthoritative off
>  require group <somegroup>
>  Allow from all
> </Directory>
> ########################
>
> When I attempt to connect to /trac_test/login (or any Trac resource) I 
> receive:
> urllib2.HTTPError: HTTP Error 401: Authorization Required
>
> I realize I may have to fiddle with cookielib (maybe not). And that will 
> be an issue for another time.
> Is there an urllib2.Request.add_header() method I should be calling 
> specifically for wsgi Trac resources? When I look at the error logs, the 
> authentication error headers look identical... so I am not sure what I 
> should be asking for. I have yet to peak into the way bitten_slave 
> authenticates... And I suppose I may have to, unless someone here has a 
> quick "Yeah... you just add_header("blah we's need special trac wsgi 
> access: %s" % hash)" :)
>
> Thanks in advance!
> Jason Miller
>

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/trac-users/-/6i-p1J4R_tUJ.
To post to this group, send email to trac-users@googlegroups.com.
To unsubscribe from this group, send email to 
trac-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.

Reply via email to