Using rest with sending post request
Çağlar Karahan
karahancaglar94 at gmail.com
Mon Aug 12 20:25:37 UTC 2024
Dear all,
I want to use the rest module to send post authentication to the server.
Related config files are shown below.
*default: *
authorize {
if ("%{Service-Type}" == "Login") {
if (&Message-Authenticator) {
rest
}
}
}
*rest:*
rest {
connect_uri = "https://127.0.0.1:4433/"
tls {
client_cert = /path/to/client/cert.pem
client_key = /path/to/client/key.key
disable_verify_peer = yes
check_cert = no
check_cert_cn = no
}
authorize {
uri = "${..connect_uri}api/v1/login"
method = 'post'
body = 'json'
tls = ${..tls}
data = '{"user": {"name":"%{User-Name}", "passwd":
"%{User-Password}"}, "attributes": {"messageAuthenticator":
"%{Message-Authenticator}", "clientIP":"%{Packet-Src-IP-Address}"}}'
header = 'Content-Type: application/json'
connect_timeout = 30
recv_timeout = 30
}
}
To test it I am using radclient with below command:
echo "Service-Type=1, User-Name=caglar,User-Password=caglar,
Message-Authenticator=0x00" | ./radclient -s -x -P udp a.b.c.d:1812 auth
shared_secret
When running freeradius in debug mode, I am seeing that below error:
*(0) rest: ERROR: Request failed: 56 - Failure when receiving data from the
peer(0) rest: ERROR: Server returned no data*
I am also testing server with curl command. And it works properly.
curl -v -k -H 'Content-Type: application/json' -d '{ "user": {
"passwd":"caglar", "name":"caglar"}, "attributes": {
"messageAuthenticator":"0x00", "clientIp": "a.b.c.d"}}' -X POST
https://127.0.0.1:4433/api/v1/login --cert /path/to/client/cert.pem --key
/path/to/client/key.key
Thanks for your support,
Caglar
More information about the Freeradius-Users
mailing list