rest modules JSON replies format and types

Louis Munro lmunro at inverse.ca
Wed Feb 3 20:02:12 CET 2016


Hello all,

I am having a bit of fun playing around with the rest module in 3.0.10 to replace a custom coded perl module.

I got it working and everything seem to work nicely but for one thing.

The documentation says that the JSON payload in the request and in the reply should be in the same format.

I have no problem with the request (since FR is encoding it anyway), and I have been able to hack a reply in the right format which is accepted by the module and sets the attributes I want, but I must concede that I am cheating a little at this point.

I am returning every attribute with the type set to “string”.

That is to say, if I get a request that looks like the following:

{
  "Called-Station-SSID": {
    "value": [
      "IofStuff"
    ],
    "type": "string"
  },
  "EAP-Type": {
    "value": [
      26
    ],
    "type": "integer"
  },
  "FreeRADIUS-Proxied-To": {
    "value": [
      "127.0.0.1"
    ],
    "type": "ipaddr"
  },
  "Location-Capable": {
    "value": [
      1
    ],
    "type": "integer"
  },
  "Tunnel-Medium-Type": {
    "value": [
      "IEEE-802"
    ],
    "type": "integer"
  },
}



My reply will actually look like:

{
  "Tunnel-Medium-Type": {
    "type": "string",
    "value": [
      6
    ]
  },
  "Tunnel-Type": {
    "type": "string",
    "value": [
      13
    ]
  },
  "Tunnel-Private-Group-ID": {
    "type": "string",
    "value": [
      2
    ]
  }
}


And yet it seems to work.

So, does FreeRADIUS actually look at those types in the JSON reply?


Should I be looking into parsing the dictionary files in my REST service to populate the reply with the correct types? 
Not that it would be that hard, but if it does not matter I can find better ways of keeping myself entertained...

Much obliged for any help,
--
Louis Munro
lmunro at inverse.ca  ::  www.inverse.ca 
+1.514.447.4918 x125  :: +1 (866) 353-6153 x125
Inverse inc. :: Leaders behind SOGo (www.sogo.nu) and PacketFence (www.packetfence.org)



More information about the Freeradius-Users mailing list