help on REST HTTP-headers

classic Classic list List threaded Threaded
5 messages Options
| Threaded
Open this post in threaded view
|

help on REST HTTP-headers

Users mailing list
 Hi All

 Very new to freeRADIUS and trying to set up a post-auth rest POST to a 3rd party system that is expecting an API-key.

So I set up rest config as

        post-auth {
            uri = "{$..connect_uri}/post"
            method = 'post'
            body = 'json'
            REST-HTTP-Header = "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
            data = '{"end-user":"radius-test"}'
            tls = ${..tls}
        }

But the debug I see from the POST server is

    Headers
    -------
    Forwarded: for="<IP@>";proto=https
    X-Cloud-Trace-Context: 0edff73713fcbb7dd9741ac6e8ca6436/18102608228808296760
    X-Forwarded-For: <IP@>, 169.254.1.1
    Content-Length: 26
    Content-Type: application/json
    X-Forwarded-Proto: https
    X-Freeradius-Section: post-auth
    X-Freeradius-Server: default
    Accept: */*
    User-Agent: FreeRADIUS 3.0.22

    Body
    ----
    {"end-user":"radius-test"}


Any idea what I'm doing wrong when trying to configure the x-api-key header?


Cheers,
Mark









-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: help on REST HTTP-headers

Jorge Pereira-2

> On 23 Jul 2020, at 16:21, Mark Grayson (mgrayson) via Freeradius-Users <[hidden email]> wrote:
>
> Hi All
>
> Very new to freeRADIUS and trying to set up a post-auth rest POST to a 3rd party system that is expecting an API-key.
>
> So I set up rest config as
>
>        post-auth {
>            uri = "{$..connect_uri}/post"

It should be:

 uri = “${..connect_uri}/post"

>            method = 'post'
>            body = 'json'
>            REST-HTTP-Header = "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
>            data = '{"end-user":"radius-test"}'
>            tls = ${..tls}
>        }
>
> But the debug I see from the POST server is
>
>    Headers
>    -------
>    Forwarded: for="<IP@>";proto=https
>    X-Cloud-Trace-Context: 0edff73713fcbb7dd9741ac6e8ca6436/18102608228808296760
>    X-Forwarded-For: <IP@>, 169.254.1.1
>    Content-Length: 26
>    Content-Type: application/json
>    X-Forwarded-Proto: https
>    X-Freeradius-Section: post-auth
>    X-Freeradius-Server: default
>    Accept: */*
>    User-Agent: FreeRADIUS 3.0.22
>
>    Body
>    ----
>    {"end-user":"radius-test"}
>
>
> Any idea what I'm doing wrong when trying to configure the x-api-key header?
>
>
> Cheers,
> Mark
>
>
>
>
>
>
>
>
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: help on REST HTTP-headers

Users mailing list
Hi Joreg

Thanks for the response!

>    It should be:
>
>     uri = “${..connect_uri}/post"

Apologies - that was my bad cut and paste (I had the full fqdn in there for testing), but yes I am indeed using

post-auth {
        uri = “${..connect_uri}/post"
        method = 'post'
        body = 'json'
        REST-HTTP-Header = "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
        data = '{"end-user":"radius-test"}'
        tls = ${..tls}
}

But still no header is being appended

Cheers,
mark

On 24/07/2020, 00:41, "Jorge Pereira" <[hidden email]> wrote:


    > On 23 Jul 2020, at 16:21, Mark Grayson (mgrayson) via Freeradius-Users <[hidden email]> wrote:
    >
    > Hi All
    >
    > Very new to freeRADIUS and trying to set up a post-auth rest POST to a 3rd party system that is expecting an API-key.
    >
    > So I set up rest config as
    >
    >        post-auth {
    >            uri = "{$..connect_uri}/post"

    It should be:

     uri = “${..connect_uri}/post"

    >            method = 'post'
    >            body = 'json'
    >            REST-HTTP-Header = "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
    >            data = '{"end-user":"radius-test"}'
    >            tls = ${..tls}
    >        }
    >
    > But the debug I see from the POST server is
    >
    >    Headers
    >    -------
    >    Forwarded: for="<IP@>";proto=https
    >    X-Cloud-Trace-Context: 0edff73713fcbb7dd9741ac6e8ca6436/18102608228808296760
    >    X-Forwarded-For: <IP@>, 169.254.1.1
    >    Content-Length: 26
    >    Content-Type: application/json
    >    X-Forwarded-Proto: https
    >    X-Freeradius-Section: post-auth
    >    X-Freeradius-Server: default
    >    Accept: */*
    >    User-Agent: FreeRADIUS 3.0.22
    >
    >    Body
    >    ----
    >    {"end-user":"radius-test"}
    >
    >
    > Any idea what I'm doing wrong when trying to configure the x-api-key header?
    >
    >
    > Cheers,
    > Mark
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > -
    > List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html



-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: help on REST HTTP-headers

Matthew Newton-3
In reply to this post by Users mailing list


On 23/07/2020 20:21, Mark Grayson (mgrayson) via Freeradius-Users wrote:

> So I set up rest config as
>
>          post-auth {
>              uri = "{$..connect_uri}/post"
>              method = 'post'
>              body = 'json'
>              REST-HTTP-Header = "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
>              data = '{"end-user":"radius-test"}'
>              tls = ${..tls}
>          }

REST-HTTP-Header is an attribute, not a config setting, so that isn't
the right place for it.


> Any idea what I'm doing wrong when trying to configure the x-api-key header?

Before you call the rest module in the post-auth section (in
sites-enabled/default), you need to set the attribute, e.g.

   update control {
     &REST-HTTP-Header := "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
   }
   rest

See the notes in raddb/mods-available/rest about that attribute, notably
that it will be consumed after the rest call, so if you are making
multiple rest calls you'll need to set it each time (using a policy may
be the cleanest way to do this).

--
Matthew
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: help on REST HTTP-headers

Users mailing list
Hi Matthew

> update control {
>     &REST-HTTP-Header := "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
>  }

Brilliant - thanks for your help!

Cheers,
Mark

On 24/07/2020, 11:20, "Freeradius-Users on behalf of Matthew Newton" <freeradius-users-bounces+mgrayson=[hidden email] on behalf of [hidden email]> wrote:



    On 23/07/2020 20:21, Mark Grayson (mgrayson) via Freeradius-Users wrote:
    > So I set up rest config as
    >
    >          post-auth {
    >              uri = "{$..connect_uri}/post"
    >              method = 'post'
    >              body = 'json'
    >              REST-HTTP-Header = "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
    >              data = '{"end-user":"radius-test"}'
    >              tls = ${..tls}
    >          }

    REST-HTTP-Header is an attribute, not a config setting, so that isn't
    the right place for it.


    > Any idea what I'm doing wrong when trying to configure the x-api-key header?

update control {
     &REST-HTTP-Header := "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
   }you need to set the attribute, e.g.

       update control {
         &REST-HTTP-Header := "x-api-key: 94332cabcdef57456582e5af2bfa123456789"
       }
       rest

    See the notes in raddb/mods-available/rest about that attribute, notably
    that it will be consumed after the rest call, so if you are making
    multiple rest calls you'll need to set it each time (using a policy may
    be the cleanest way to do this).

    --
    Matthew
    -
    List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html