Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with packet reply-message #121

Open
deusyv opened this issue Dec 17, 2019 · 4 comments
Open

problem with packet reply-message #121

deusyv opened this issue Dec 17, 2019 · 4 comments
Assignees
Labels
feedback feedback required fixed

Comments

@deusyv
Copy link

deusyv commented Dec 17, 2019

Bug in 2.2 : no problem in 2.1
Traceback (most recent call last):

File "/app/uti/project/views.py", line 81, in do_admin_login
reply = srv.SendPacket(req)
File "/app/venv-3.6/lib/python3.6/site-packages/pyrad/client.py", line 180, in SendPacket
return self._SendPacket(pkt, self.authport)
File "/app/venv-3.6/lib/python3.6/site-packages/pyrad/client.py", line 160, in _SendPacket
reply = pkt.CreateReply(packet=rawreply)
File "/app/venv-3.6/lib/python3.6/site-packages/pyrad/packet.py", line 620, in CreateReply
**attributes)
File "/app/venv-3.6/lib/python3.6/site-packages/pyrad/packet.py", line 609, in init
Packet.init(self, code, id, secret, authenticator, **attributes)
File "/app/venv-3.6/lib/python3.6/site-packages/pyrad/packet.py", line 99, in init
self.DecodePacket(attributes['packet'])
File "/app/venv-3.6/lib/python3.6/site-packages/pyrad/packet.py", line 542, in DecodePacket
elif self.dict.attributes[self._DecodeKey(key)].type == 'tlv':
KeyError: 18

problem with packet reply-message
in radius users file:
DEFAULT Group == "motor", NAS-Identifier == "10.205.21.150"
Reply-Message = "motor"

@kkirsche
Copy link

kkirsche commented Jan 8, 2020

I'm getting the same error but due to KeyError 80:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/

Django Version: 3.0.2
Python Version: 3.7.6
Installed Applications:
['dashboard.apps.DashboardConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'crispy_forms']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.RemoteUserMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 407, in login
    return LoginView.as_view(**defaults)(request)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/views.py", line 63, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/edit.py", line 141, in post
    if form.is_valid():
  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 180, in is_valid
    return self.is_bound and not self.errors
  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 175, in errors
    self.full_clean()
  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 377, in full_clean
    self._clean_form()
  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 404, in _clean_form
    cleaned_data = self.clean()
  File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/forms.py", line 214, in clean
    self.user_cache = authenticate(self.request, username=username, password=password)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/__init__.py", line 72, in authenticate
    user = backend.authenticate(request, **credentials)
  File "/usr/local/lib/python3.7/site-packages/radiusauth/backends/radius.py", line 209, in authenticate
    result = self._radius_auth(server, username, password)
  File "/usr/local/lib/python3.7/site-packages/radiusauth/backends/radius.py", line 172, in _radius_auth
    return self._perform_radius_auth(client, packet)
  File "/usr/local/lib/python3.7/site-packages/radiusauth/backends/radius.py", line 119, in _perform_radius_auth
    reply = client.SendPacket(packet)
  File "/usr/local/lib/python3.7/site-packages/pyrad/client.py", line 180, in SendPacket
    return self._SendPacket(pkt, self.authport)
  File "/usr/local/lib/python3.7/site-packages/pyrad/client.py", line 161, in _SendPacket
    if pkt.VerifyReply(reply, rawreply):
  File "/usr/local/lib/python3.7/site-packages/pyrad/packet.py", line 400, in VerifyReply
    attr = reply._PktEncodeAttributes()
  File "/usr/local/lib/python3.7/site-packages/pyrad/packet.py", line 459, in _PktEncodeAttributes
    if self.dict.attributes[self._DecodeKey(code)].type == 'tlv':

Exception Type: KeyError at /admin/login/
Exception Value: 80

kkirsche added a commit to kkirsche/django-radius that referenced this issue Jan 30, 2020
pyrad 2.2. errors out during the authentication process, this modifies the install requires to avoid the broken version

See issue on pyrad for more details of the issue
pyradius/pyrad#121
@GIC-de GIC-de self-assigned this Feb 5, 2020
@GIC-de GIC-de closed this as completed in f07c84d Feb 5, 2020
@GIC-de GIC-de reopened this Feb 5, 2020
@GIC-de GIC-de added feedback feedback required fixed labels Feb 5, 2020
@GIC-de
Copy link
Collaborator

GIC-de commented Feb 5, 2020

@deusyv this should be fixed with latest master (f07c84d)! Would be nice if you can verify!!!

Sending authentication request
Traceback (most recent call last):
  File "auth.py", line 23, in <module>
    reply = srv.SendPacket(req)
  File "/Users/gic/Virtualenvs/P3P/projects/pyrad/pyrad/client.py", line 180, in SendPacket
    return self._SendPacket(pkt, self.authport)
  File "/Users/gic/Virtualenvs/P3P/projects/pyrad/pyrad/client.py", line 161, in _SendPacket
    if pkt.VerifyReply(reply, rawreply):
  File "/Users/gic/Virtualenvs/P3P/projects/pyrad/pyrad/packet.py", line 400, in VerifyReply
    attr = reply._PktEncodeAttributes()
  File "/Users/gic/Virtualenvs/P3P/projects/pyrad/pyrad/packet.py", line 459, in _PktEncodeAttributes
    if self.dict.attributes[self._DecodeKey(code)].type == 'tlv':
KeyError: 18

After Fix:

Sending authentication request
Access accepted
Attributes returned by server:
Service-Type: ['Framed-User']
Framed-IP-Address: ['192.168.0.1']
Framed-IPv6-Prefix: ['fc66::1/64']
18: [b'motor']

I will generate next version ASAP.

@GIC-de
Copy link
Collaborator

GIC-de commented Feb 5, 2020

Fixed in 2.3 (https://pypi.org/project/pyrad/)

@fragfutter
Copy link

feedback: upgrading from 2.2 to 2.3 fixed it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback feedback required fixed
Projects
None yet
Development

No branches or pull requests

4 participants