背景
最近用到freeradius做認證, 其中涉及到"unlang"語法, 整理一下.
參考: https://freeradius.org/radiusd/man/unlang.html
關於FreeRadius本人也不是很熟悉, 只因用到才學了其中一部分, 如有問題請指出, 共同學習.
重要部分會加粗顯示, 如有錯誤請指出, 非常感謝.
“unlang”
名稱
unlang - FreeRADIUS 處理的"非語言"(“un-language”)
概述
FreeRADIUS 在它的配置文件中支持一種簡單的處理語言. 我們稱之爲"非語言"(“un-language”), 因爲並不是想創造另一種編程語言.
如果你需要比這裏描述的更復雜的功能, 我們建議你使用Perl或者Python模塊: rlm_perl
或者rlm_python
.
這個語言的目標是容易書寫簡單的策略. 當一個請求被處理時這些策略會被應用.
在"授權"(authorize), “認證”(authenticate), “認證後”(post-auth), 計費前(preacct), “計費中”(accounting), “代理前”(pre-proxy), “代理後”(post-proxy), 和"會話"(session)這些部分, 請求通過虛擬服務器處理(包括默認的那個).
這些策略不能被用在配置文件的其他部分, 比如模塊(module)或者客戶端配置.
關鍵字
if (condition) {
} elsif (condition) {
} else {
}
// Foreach-Variable-#
// 其中#是循環的深度, 從0開始, 如Foreach-Variable-0, Foreach-Variable-1等
foreach &Attribute-Reference {
Foreach-Variable-#
}
switch <argument> {
case <argument> {
}
case <argument> {
}
// default
case {
}
}
update可以修改某個list中的屬性(key),
list可以爲: “request”, “reply”, “proxy-request”, “proxy-reply”, “coa”, “disconnect”, “session-state”, 或者 “control”.
在版本3中, 可以省略, 此時它爲"request"
update <list> {
&Attribute-Reference = value
}
return
(未完待續)