title: freeradius 3.0.17 rlm_rest parsing json response
body: <p>I'm trying to authenticate RADIUS Requests against a RESTful API (provided by Customer) using rlm_rest.</p>
  
  <p>The problem I am facing is that
  response JSON format (of REST API provided by Customer), is different from rlm_rest default format (indicated in <a href="https://gist.github.com/nemesisdesign/c72d53d5c9bbfee4c03f1f2cb9afc7cb" rel="nofollow noreferrer">etc/raddb/mods-enabled/rest</a>).</p>
  
  <p>My Virtual Server configuration as below:</p>
  
  <h2>Default</h2>
  
  <pre><code>authorize {
  ...
  ...
  rest
  if (ok) {
      update control {
          Auth-Type := rest
          }
      }
  }
  </code></pre>
  
  <h2>mods-enabled/rest</h2>
  
  <pre><code>authorize {
      uri = "https://3rd-party-API/auth"
      method = 'post'
      body = 'json'
      chunk = 0
      tls = ${..tls}
      data = '{
          "code": 1,
          "identifier": %I,
          "avps": {
              "User-Name": ["%{User-Name}"],
              "NAS-IP-Address": ["%{NAS-IP-Address}"],
              "Called-Station-Id": ["%{Called-Station-Id}"],
              "Calling-Station-Id": ["%{Calling-Station-Id}"],
              "NAS-Identifier": ["%{NAS-Identifier}"]
          }
      }'
  }
  </code></pre>
  
  <h1>Result</h1>
  
  <p>/sbin/radiusd -Xxx</p>
  
  <p>HTTP response code</p>
  
  <pre><code>200
  </code></pre>
  
  <p>JSON Body</p>
  
  <pre><code>{
      "code": "2",
      "identifier": "91",
      "avps": {
          "Customer-Attributes": "Hello"
          ...
          ...
          "Acct-Interim-Interval": "300"
      }
  }
  </code></pre>
  
  <p>The JSON structure is different from the example, and xlat parse
      "code"
      "identifier"
      "avps"</p>
  
  <p>And, of course, xlat finds no attributes match with the dictionary, while it cannot find "avps" and won't dig deeper.</p>
  
  <p>So I was wondering is there anyway to either</p>
  
  <ol>
  <li>Define the response JSON structure for xlat to parsing</li>
  <li>Insert a "is_json" or "do_xlat" flag into the JSON ("avps"), and hope xlat will then dig deeper</li>
  <li>Save the JSON and parse with exec/rlm_exec (using JQ or any other bash/JSON tools)</li>
  </ol>
  
  <p>Please advise if there is any workaround. Thanks!</p>