pyrad icon indicating copy to clipboard operation
pyrad copied to clipboard

tagged attributes support

Open alexander-bespalov opened this issue 8 years ago • 3 comments

Does pyrad support tagged attributes? If yes, can somebody please share example how to use / parse them?

I'm working on client application and RADIUS server is replying with several tagged instances of attribute (tag=2 and tag=5): ERX-Service-Activate: [u'\x02INTERNET(1000000,1000000)', u'\x05TEST']

From server side: Sending Access-Accept Id 137 from 127.0.0.1:1812 to 127.0.0.1:43556 Framed-IP-Address = 1.2.3.4 ERX-Service-Activate:2 = 'INTERNET(1000000,1000000)' ERX-Service-Activate:5 = 'TEST'

Thanks!

alexander-bespalov avatar Mar 24 '17 13:03 alexander-bespalov

pyrad supports sending of tagged attributes but not receiving

GIC-de avatar Mar 24 '17 14:03 GIC-de

Here an example how to parse tagged attributes with current pyrad version. I will try to improve this in future releases:

...
import struct
...

class FakeServer(server.Server):

    def HandleAuthPacket(self, pkt):
        print("Received an authentication request")
        print("Attributes: ")
        for attr in pkt.keys():
            def print_attributes(attr, value):
                # check if attribute has tag
                if self.dict[attr].has_tag:
                    # unpack tag and value
                    fmt = "B%ds" % (len(value) - 1)
                    _attr = struct.unpack_from(fmt, value, 0)
                    tag = _attr[0]
                    value = "".join(_attr[1:])
                    # print output
                    print("%s:%s = %s" % (attr, tag, value))
                else:
                    print("%s = %s" % (attr, value))

            # check if attribute value is list
            if isinstance(pkt[attr], list):
                for v in pkt[attr]:
                    print_attributes(attr, v)
            else:
                print_attributes(attr, pkt[attr])

GIC-de avatar Mar 24 '17 16:03 GIC-de

This issue keeps open because support for receiving tagged attributes is still missing.

GIC-de avatar Jul 05 '18 21:07 GIC-de