Thanks,

so running the script from https://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Displaying_Request_Environment gave me

PID: 2107
UID: 48
GID: 48

DOCUMENT_ROOT: '/var/www/'
GATEWAY_INTERFACE: 'CGI/1.1'
HTTP_ACCEPT: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
HTTP_ACCEPT_ENCODING: 'gzip, deflate'
HTTP_ACCEPT_LANGUAGE: 'de'
HTTP_CONNECTION: 'keep-alive'
HTTP_HOST: '*.*.*.211'
HTTP_USER_AGENT: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0'
PATH_INFO: ''
QUERY_STRING: ''
REMOTE_ADDR: '*.*.*.219'
REMOTE_PORT: '50314'
REQUEST_METHOD: 'GET'
REQUEST_URI: '/test'
SCRIPT_FILENAME: '/var/www/trac/cgi-bin/display_request_environment.wsgi'
SCRIPT_NAME: '/test'
SERVER_ADDR: '*.*.*.211'
SERVER_ADMIN: 'root@localhost'
SERVER_NAME: '*.*.*.211'
SERVER_PORT: '80'
SERVER_PROTOCOL: 'HTTP/1.1'
SERVER_SIGNATURE: '<address>Apache/2.2.15 (Red Hat) Server at *.*.*.211 Port 80</address>\n'
SERVER_SOFTWARE: 'Apache/2.2.15 (Red Hat)'
mod_ssl.is_https: <built-in method ssl_is_https of mod_wsgi.Adapter object at 0x7f9d87744a80> mod_ssl.var_lookup: <built-in method ssl_var_lookup of mod_wsgi.Adapter object at 0x7f9d87744a80>
mod_wsgi.application_group: ''
mod_wsgi.callable_object: 'application'
mod_wsgi.handler_script: ''
mod_wsgi.input_chunked: '0'
mod_wsgi.listener_host: ''
mod_wsgi.listener_port: '80'
mod_wsgi.process_group: ''
mod_wsgi.request_handler: 'wsgi-script'
mod_wsgi.script_reloading: '1'
mod_wsgi.version: (3, 2)
wsgi.errors: <mod_wsgi.Log object at 0x7f9d87757d70>
wsgi.file_wrapper: <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f9d87744a80>
wsgi.input: <mod_wsgi.Input object at 0x7f9d87757d30>
wsgi.multiprocess: True
wsgi.multithread: False
wsgi.run_once: False
wsgi.url_scheme: 'http'
wsgi.version: (1, 1)

meanwhile I will try to follow your advice about https and the rewrite rule.

Eberhardt

Zitat von "Cooke, Mark" <[email protected]>:

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Cooke, Mark
Sent: 29 October 2014 08:55
To: [email protected]
Subject: RE: [Trac] Trac issue with permission for ldap users

[Replying in-line below...]

> Zitat von "Cooke, Mark" <[email protected]>:
>
> >> -----Original Message-----
> >> From: [email protected] [mailto:[email protected]]
On
> >> Behalf Of Jan Eberhardt
> >>
> >>
> >> Hello trac-team and/or mailinglist users,
> >>
> >> I am using LDAP for authentication and I want to define permissions
> >> for every single user that logged in via LDAP.
> >> When I login (LDAP is working), the permissions of the 'authenticated'
> >> group are matched to the login user (seems right so far), but I also
> >> did 'trac-admin <env> permission add <username>'. I gave this user
> >> (matching the LDAP login) higher permissions, but they dont apply.
> >>
> >> An example:
> >> LDAP Login for the user is 'bob', I also create 'trac-admin <env>
> >> permission add bob TRAC_ADMIN', but when I login as 'bob' I dont see
> >> the admin-panel.
> >>
> >> The 'admin' user works right (authenticated via local htpasswd file),
> >> but when I want to grant the LDAP users higher rights, it fails.
> >>
> >> What goes wrong, where do I fail ?
> >
> > What messages (if any) do you get in your apache log files?
> >
> > Can you show us the relevant bits of your apache `conf` file and
> > your wsgi files?
> >
> > As a quick suggestion, is this a case issue?  I have the following
> > line in my WSGI file:
> >
> >     # Make sure usernames are lower case...
> >     environ['REMOTE_USER'] = environ['REMOTE_USER'].lower()
> >
> > ...or a domain issue...
> >
> >     # Strip any domain if present
> >     while "\\" in environ['REMOTE_USER']:
> > environ['REMOTE_USER'] = environ['REMOTE_USER'].split("\\", 1)[1]
> >
> > Hope that helps,
> >
> > ~ Mark C
> >
> >> Kind regards
> >> Eberhardt
> >>
> >> --
> >> Trac-System:
> >>   - Red Hat Linux
> >>   - apache (with mod_wsgi, mod_ldap, mod_authnz_ldap)
> >>   - MySQL
> >
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Jan Eberhardt
>
> Hi,
> editing my trac.wsgi (with the proposed snippet), gave me an "500
> Internal error" and following message in my apache error log:
>
> [Thu Oct 23 22:55:39 2014] [error] [client *] mod_wsgi (pid=27135):
> Exception occurred processing WSGI script
> '/var/www/trac/cgi-bin/trac.wsgi'.
> [Thu Oct 23 22:55:39 2014] [error] [client *] Traceback (most recent
> call last):
> [Thu Oct 23 22:55:39 2014] [error] [client *]   File
> "/var/www/trac/cgi-bin/trac.wsgi", line 33, in application
> [Thu Oct 23 22:55:39 2014] [error] [client *]
> environ['REMOTE_USER'] = environ['REMOTE_USER'].lower()
> [Thu Oct 23 22:55:39 2014] [error] [client *] KeyError: 'REMOTE_USER'

This is the important bit.  mod_wsgi can only pass on data set by the apache
modules that handle your authentication. That is not setting the remote user
variable and therefore there is no "REMOTE_USER" to pass on to Trac...

Update: I remembered I had a script to display the WSGI environment back to the browser so I could check what was and was not available. Searching for it I re-found Graham Dumpleton's excellent mod_wsgi docs and a section specifically for this:-

https://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Displaying_Request_Environment

Try that out and let us know what you get... You need to make sure that the "REMOTE_USER" is being set before Trac can see who "you" are.

~ Mark C

> My trac.wsgi (without your proposal):
>
> import os
>
> def application(environ, start_request):
>      if not 'trac.env_parent_dir' in environ:
>          environ.setdefault('trac.env_path', '/var/www/trac')
>      if 'PYTHON_EGG_CACHE' in environ:
>          os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
>      elif 'trac.env_path' in environ:
>          os.environ['PYTHON_EGG_CACHE'] = \
>              os.path.join(environ['trac.env_path'], '.egg-cache')
>      elif 'trac.env_parent_dir' in environ:
>          os.environ['PYTHON_EGG_CACHE'] = \
>              os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
>      os.environ['PYTHON_EGG_CACHE'] = '/tmp/python-eggs'
>      from trac.web.main import dispatch_request
>      return dispatch_request(environ, start_request)
>
> My trac-apache.conf:
>
> LDAPVerifyServerCert Off
> <LocationMatch "/trac/login">
>      AuthName "Trac LDAP Authentication"
>      AuthType Basic
>      AuthBasicProvider ldap file
>      AuthzLDAPAuthoritative Off
>      AuthUserFile /opt/trac-password/trac.htpasswd
>      AuthLDAPURL "ldaps://DOMAIN:PORT/ou=OU,o=O,dc=DC,dc=DC?uid?"
>      Require ldap-user USER USER USER
>      Require user admin
> </LocationMatch>

Hmm, my apache-fu may be letting me down here but I think the problem is you
are only protecting the login page?

I have configured my server to redirect (almost *) everything to https using
a RewriteRule. After that, the whole server requires authentication (using a
<Location /> block in the SSL conf file).

(*) I have set up some exceptions to serve the static trac resources:
{{{
RewriteCond %{REQUEST_URI} !/trac/common/"
RewriteRule ^/(.*) https://server/$1 [R=permanent,L]
}}}

Another possible issue is with your LDAP query.  If you are using Active
Directory then you may want to use "sAMAccountName" instead of "uid"?

I hope one or both of those ideas help...

~ Mark C

> WSGIScriptAlias /trac /var/www/trac/cgi-bin/trac.wsgi
> <Directory "/var/www/trac/cgi-bin">
>      WSGIApplicationGroup %{GLOBAL}
>      Order deny,allow
>      Allow from all
> </Directory>
>
> Alias /trac/chrome/common /var/www/trac/htdocs/common
> Alias /trac/chrome/site /var/www/trac/htdocs/site
> <Directory "/var/www/trac/htdocs">
>      Order allow,deny
>      Allow from all
> </Directory>
>
> That is my config.
>
> Kind regards
> Eberhardt
>

--
You received this message because you are subscribed to the Google Groups
"Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to