Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#8918 closed defect (fixed)

Wrong key name in source code, auth.py line 165 — at Version 5

Reported by: cory.pedersen@… Owned by: John Hampton
Priority: normal Component: DirectoryAuthPlugin
Severity: critical Keywords:
Cc: Trac Release: 0.11

Description (last modified by Ryan J Ollos)

There is an error in the source code, auth.py, line 165. I believe the line should read:

for e in attrs['proxyAddress'''es'''']:

Currently, I am getting a KeyError since the attribute from Active Directory should be proxyAddresses not proxyAddress.

Error log:

Traceback (most recent call last):
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\api.py", line 440, in send_error
    data, 'text/html')
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\chrome.py", line 833, in render_template
    data = self.populate_data(req, data)
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\chrome.py", line 744, in populate_data
    'context': req and Context.from_request(req) or None,
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\mimeview\api.py", line 156, in from_request
    perm = req.perm
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\api.py", line 216, in __getattr__
    value = self.callbacks[name](self)
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\main.py", line 293, in _get_perm
    if isinstance(req.session, FakeSession):
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\api.py", line 216, in __getattr__
    value = self.callbacks[name](self)
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\main.py", line 300, in _get_session
    return Session(self.env, req)
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\session.py", line 192, in __init__
    if req.authname == 'anonymous':
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\api.py", line 216, in __getattr__
    value = self.callbacks[name](self)
  File "c:\docume~1\ccs~2.gis\locals~1\temp\easy_install-riokcd\Trac-0.12.2-py2.5-win32.egg.tmp\trac\web\main.py", line 159, in authenticate
    authname = authenticator.authenticate(req)
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 490, in wrap
    return func(self, *args, **kwds)
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 500, in authenticate
    user = self._remote_user(req)
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 706, in _remote_user
    if acctmgr.check_password(user, password) == True:
  File "build\bdist.win32\egg\acct_mgr\api.py", line 284, in check_password
    valid = store.check_password(user, password)
  File "build\bdist.win32\egg\tracext\adauth\auth.py", line 86, in check_password
    dn = self._get_user_dn(user)
  File "build\bdist.win32\egg\tracext\adauth\auth.py", line 144, in _get_user_dn
    if self.has_user(user):
  File "build\bdist.win32\egg\tracext\adauth\auth.py", line 81, in has_user
    users = self.get_users()
  File "build\bdist.win32\egg\tracext\adauth\auth.py", line 50, in get_users
    userinfo = [self._get_userinfo(u[1]) for u in users]
  File "build\bdist.win32\egg\tracext\adauth\auth.py", line 165, in _get_userinfo
    for e in attrs['proxyAddress']:
KeyError: 'proxyAddress'

Change History (4)

comment:2 Changed 13 years ago by Nathan Lewis

I got the same error and changed the proxyAddress to proxyAddresses and got a different error that doesn't really make sense. I am on version 0.12.

Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/web/api.py", line 436, in send_error
    data, 'text/html')
  File "build/bdist.linux-i686/egg/trac/web/chrome.py", line 809, in render_template
    data = self.populate_data(req, data)
  File "build/bdist.linux-i686/egg/trac/web/chrome.py", line 720, in populate_data
    'context': req and Context.from_request(req) or None,
  File "build/bdist.linux-i686/egg/trac/mimeview/api.py", line 156, in from_request
    perm = req.perm
  File "build/bdist.linux-i686/egg/trac/web/api.py", line 212, in __getattr__
    value = self.callbacks[name](self)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 291, in _get_perm
    if isinstance(req.session, FakeSession):
  File "build/bdist.linux-i686/egg/trac/web/api.py", line 212, in __getattr__
    value = self.callbacks[name](self)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 298, in _get_session
    return Session(self.env, req)
  File "build/bdist.linux-i686/egg/trac/web/session.py", line 156, in __init__
    if req.authname == 'anonymous':
  File "build/bdist.linux-i686/egg/trac/web/api.py", line 212, in __getattr__
    value = self.callbacks[name](self)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 157, in authenticate
    authname = authenticator.authenticate(req)
  File "build/bdist.linux-i686/egg/acct_mgr/web_ui.py", line 488, in wrap
    return func(self, *args, **kwds)
  File "build/bdist.linux-i686/egg/acct_mgr/web_ui.py", line 509, in authenticate
    user = self._remote_user(req)
  File "build/bdist.linux-i686/egg/acct_mgr/web_ui.py", line 747, in _remote_user
    if acctmgr.check_password(user, password) == True:
  File "build/bdist.linux-i686/egg/acct_mgr/api.py", line 303, in check_password
    valid = store.check_password(user, password)
  File "/usr/lib/python2.5/site-packages/TracActiveDirectoryAuth-0.2.2-py2.7.egg/tracext/adauth/auth.py", line 86, in check_password
    dn = self._get_user_dn(user)
  File "/usr/lib/python2.5/site-packages/TracActiveDirectoryAuth-0.2.2-py2.7.egg/tracext/adauth/auth.py", line 144, in _get_user_dn
    if self.has_user(user):
  File "/usr/lib/python2.5/site-packages/TracActiveDirectoryAuth-0.2.2-py2.7.egg/tracext/adauth/auth.py", line 81, in has_user
    users = self.get_users()
  File "/usr/lib/python2.5/site-packages/TracActiveDirectoryAuth-0.2.2-py2.7.egg/tracext/adauth/auth.py", line 50, in get_users
    userinfo = [self._get_userinfo(u[1]) for u in users]
  File "/usr/lib/python2.5/site-packages/TracActiveDirectoryAuth-0.2.2-py2.7.egg/tracext/adauth/auth.py", line 159, in _get_userinfo
    username = attrs['sAMAccountName'][0].lower()
KeyError: 'sAMAccountName'

comment:3 Changed 13 years ago by myinglingatxenotrandotcom

Using trunk in Trac 0.12, I got a similar error showing that a list (listType) was returned, not the expected dictionary (dictType).

  File "/usr/local/lib/python2.6/dist-packages/TracActiveDirectoryAuth-0.2.2-py2.6.egg/tracext/adauth/auth.py", line 173, in _get_userinfo
    username = attrs['sAMAccountName'][0].lower()
TypeError: list indices must be integers, not str

I fixed it by adding an auth_group to filter out the "ldap://ForestDnsZones..." that were being returned by my DC as a list in Python and messing up the _get_userinfo() call. I'm not familiar enough with Python to write a filter on this so the default behavior works without defining auth_group.

comment:4 Changed 12 years ago by branson

Resolution: fixed
Status: newclosed

the sAMAccountName issue has been resolved in #9218 and pushed to 0.3 .. not sure about the ProxyAddress issue .. I see the code .. and it does look wrong .. but I don't know which is valid 'ProxyAddress' or 'ProxyAddresses' .. I assume the latter per comments above .. and will include that in 0.3

comment:5 Changed 12 years ago by Ryan J Ollos

Description: modified (diff)
Note: See TracTickets for help on using tickets.