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

Unknown attribute causes exception #9

Open
mqgmaster opened this issue Apr 27, 2018 · 5 comments
Open

Unknown attribute causes exception #9

mqgmaster opened this issue Apr 27, 2018 · 5 comments

Comments

@mqgmaster
Copy link

The following lines causes an exception when a unknown attribute is received from server.

        """
        Add an item to attributes (by name or id)
        """
        try:
            code, name = self.__getkeys(key)
        except KeyError:
            raise ValueError('Invalid radius attribute: %s' % key)
        values = self.get(code, [])
        values.append(value)
        UserDict.__setitem__(self, code, values)

The correct, in my opinion, is log a warning and continue the authentication. That lib does not need to validate the attributes, this is responsibility of the application using py-radius.

        try:
            code, name = self.__getkeys(key)
            values = self.get(code, [])
            values.append(value)
            UserDict.__setitem__(self, code, values)
        except KeyError:
            LOGGER.warning('Invalid radius attribute: %s' % key)
@btimby
Copy link
Owner

btimby commented May 4, 2018

Good point, your solution still validates the attributes, disallowing caller from using unknown attributes.

I think if key is a code, we can warn via logger and proceed to add the attribute anyway. When key is a name, it must be known so we can look up the code.

@btimby
Copy link
Owner

btimby commented May 4, 2018

#10

@btimby
Copy link
Owner

btimby commented May 4, 2018

Does the PR address your problem?

@mqgmaster
Copy link
Author

mqgmaster commented May 23, 2018

Thanks @btimby. Your solution looks better.

As soon as possible I will update my code to validate the behavior.

@btimby
Copy link
Owner

btimby commented May 23, 2018

@mqgmaster Thank you sir! Please let me know.

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

No branches or pull requests

2 participants