我也有类似的问题,比如这个one。在我的例子中,我试图在API端执行所有的逻辑。API看起来很好,拒绝无效的用户已经很好了。问题是使用API返回的属性进行身份验证。FreeRADIUS的rest模块在重新分析响应返回一些属性并无法进行身份验证后发出一个更新comand。
我的配置如下所示:
authorize {
rest
if (ok) {
update control {
Auth-Type := rest
}
}
}逻辑是:签入授权,如果用户退出(APi响应状态代码204),然后执行身份验证。身份验证将用户名和密码发送给API。API检查一些信息,然后以正确的JSON格式返回状态代码200和属性,如果一切正常的话。
如果我将API设置为使用状态代码204 (而不是200个用户)进行响应,则身份验证是正常的(但没有任何属性)。
日志:
(0) Received Access-Request Id 91 from 127.0.0.1:57293 to 127.0.0.1:1812 length 75
(0) User-Name = "admin"
(0) User-Password = "1234"
(0) NAS-IP-Address = 10.99.99.1
(0) NAS-Port = 0
(0) Message-Authenticator = 0x506aba80999c45a4c52d7c5544073969
(0) # Executing section authorize from file /usr/local/etc/raddb/sites-enabled/nano
(0) authorize {
rlm_rest (rest): Reserved connection (0)
(0) rest: Expanding URI components
(0) rest: EXPAND http://127.0.0.1:4000
(0) rest: --> http://127.0.0.1:4000
(0) rest: EXPAND /check/%{User-Name}
(0) rest: --> /check/admin
(0) rest: Sending HTTP GET to "http://127.0.0.1:4000/check/admin"
(0) rest: Processing response header
(0) rest: Status : 204 (No Content)
rlm_rest (rest): Released connection (0)
Need 5 more connections to reach 10 spares
rlm_rest (rest): Opening additional connection (5), 1 of 27 pending slots used
rlm_rest (rest): Connecting to "http://127.0.0.1:4000/"
(0) [rest] = ok
(0) if (ok) {
(0) if (ok) -> TRUE
(0) if (ok) {
(0) update control {
(0) Auth-Type := rest
(0) } # update control = noop
(0) } # if (ok) = noop
(0) } # authorize = ok
(0) Found Auth-Type = rest
(0) # Executing group from file /usr/local/etc/raddb/sites-enabled/nano
(0) authenticate {
rlm_rest (rest): Reserved connection (1)
(0) rest: Expanding URI components
(0) rest: EXPAND http://127.0.0.1:4000
(0) rest: --> http://127.0.0.1:4000
(0) rest: EXPAND /auth/%{User-Name}/%{User-Password}
(0) rest: --> /auth/admin/1234
(0) rest: Sending HTTP GET to "http://127.0.0.1:4000/auth/admin/1234"
(0) rest: Processing response header
(0) rest: Status : 200 (OK)
(0) rest: Type : json (application/json)
(0) rest: Parsing attribute "WISPr-Bandwidth-Max-Down"
(0) rest: EXPAND 3000
(0) rest: --> 3000
(0) rest: WISPr-Bandwidth-Max-Down := 3000
(0) rest: Parsing attribute "WISPr-Bandwidth-Max-Up"
(0) rest: EXPAND 1000
(0) rest: --> 1000
(0) rest: WISPr-Bandwidth-Max-Up := 1000
rlm_rest (rest): Released connection (1)
(0) [rest] = updated
(0) } # authenticate = updated
(0) Failed to authenticate the user
(0) Using Post-Auth-Type Reject
(0) Post-Auth-Type sub-section not found. Ignoring.
(0) # Executing group from file /usr/local/etc/raddb/sites-enabled/nano
(0) Delaying response for 1.000000 seconds
Waking up in 0.3 seconds.
Waking up in 0.6 seconds.
(0) Sending delayed response
(0) Sent Access-Reject Id 91 from 127.0.0.1:1812 to 127.0.0.1:57293 length 44
(0) WISPr-Bandwidth-Max-Down = 3000
(0) WISPr-Bandwidth-Max-Up = 1000
Waking up in 3.9 seconds.
(0) Cleaning up request packet ID 91 with timestamp +9提前谢谢你的提示。
发布于 2017-05-23 15:08:00
是的,我想我在4.0.x版中修正了这个。这是一些遗留问题,因为“更新”不是一个可接受的返回代码。
可以使用以下方法重写返回代码和优先级:
authenticate {
Auth-Type rest {
rest {
updated = 1
}
if (updated) {
ok
}
}
}为了解释-每个返回代码'ok','noop','fail‘等等.根据章节的不同,有不同的优先事项和行动。模块的返回代码只更新具有较高优先级的区段返回代码。
有一个神奇的优先级‘返回’,使服务器立即退出该部分。它是为身份验证部分中的大多数返回代码设置的。
我们需要重写rest模块调用的优先级,这样解释器在不评估条件if (updated)的情况下不会返回身份验证。在上面的例子中,我们将更新的优先级设置为1,确保以后可以覆盖它。
https://stackoverflow.com/questions/44137847
复制相似问题