如果雙因素身份驗證既可取又棘手,但沒有錢購買硬件令牌,而且一般來說它們可以保持良好的心情,該怎麼辦?
該解決方案並不是超級原創,而是在互聯網上找到的不同解決方案的混合。
所以給出
域名 活動目錄.
域用戶通過 VPN 工作,就像當今的許多用戶一樣。
充當 VPN 網關 加強.
安全策略禁止保存 VPN 客戶端的密碼。
政治 Fortinet公司 就您自己的代幣而言,您不能將其稱為低於 zhlob - 有多達 10 個免費代幣,其餘的 - 以非常不合規的價格。 我沒有考慮RSASecureID、Duo之類的,因為我想要開源。
先決條件: 主持人 * nix中 與既定的 FreeRADIUS的, 固態硬盤 - 輸入域,域用戶可以輕鬆地在其上進行身份驗證。
附加套餐: 謝麗娜盒子, 無花果, freeradius LDAP, 字體 反叛者.tlf 從存儲庫
在我的示例中 - CentOS 7.8。
工作邏輯應該如下:連接到 VPN 時,用戶必須輸入域登錄名和 OTP,而不是密碼。
服務設置
В /etc/raddb/radiusd.conf 僅代表其啟動的用戶和組 FreeRADIUS的,自從服務 半徑 應該能夠讀取所有子目錄中的文件 /家/.
user = root
group = root
能夠在設置中使用組 加強, 必須傳送 供應商特定屬性. 為此,請在目錄中 raddb/policy.d 我創建一個包含以下內容的文件:
group_authorization {
if (&LDAP-Group[*] == "CN=vpn_admins,OU=vpn-groups,DC=domain,DC=local") {
update reply {
&Fortinet-Group-Name = "vpn_admins" }
update control {
&Auth-Type := PAM
&Reply-Message := "Welcome Admin"
}
}
else {
update reply {
&Reply-Message := "Not authorized for vpn"
}
reject
}
}
安裝後 freeradius LDAP 在目錄中 raddb/mods-可用 文件已創建 LDAP.
需要創建目錄的符號鏈接 啟用 raddb/mods.
ln -s /etc/raddb/mods-available/ldap /etc/raddb/mods-enabled/ldap
我把它的內容變成這樣的形式:
ldap {
server = 'domain.local'
identity = 'CN=freerad_user,OU=users,DC=domain,DC=local'
password = "SupeSecretP@ssword"
base_dn = 'dc=domain,dc=local'
sasl {
}
user {
base_dn = "${..base_dn}"
filter = "(sAMAccountname=%{%{Stripped-User-Name}:-%{User-Name}})"
sasl {
}
scope = 'sub'
}
group {
base_dn = "${..base_dn}"
filter = '(objectClass=Group)'
scope = 'sub'
name_attribute = cn
membership_filter = "(|(member=%{control:Ldap-UserDn})(memberUid=%{%{Stripped-User-Name}:-%{User-Name}}))"
membership_attribute = 'memberOf'
}
}
在文件中 raddb/啟用站點/默認 и raddb/啟用站點/內部隧道 在部分 授權 我添加要使用的策略的名稱 - group_authorization。 重要的一點 - 策略的名稱不是由目錄中的文件名決定的 政策.d,但是通過文件內大括號之前的指令進行。
在該部分 認證 在相同的文件中,您需要取消註釋該行 PAM.
在文件中 客戶配置文件 規定它將連接的參數 加強:
client fortigate {
ipaddr = 192.168.1.200
secret = testing123
require_message_authenticator = no
nas_type = other
}
模塊配置 pam.d/radiusd:
#%PAM-1.0
auth sufficient pam_google_authenticator.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
session include password-auth
默認捆綁包實現選項 FreeRADIUS的 с 谷歌驗證器 要求用戶以以下格式輸入憑據: 用戶名密碼+OTP.
想像一下在使用默認捆綁包的情況下,落在頭上的詛咒數量 FreeRADIUS的 с 谷歌的Authenticator,決定使用模塊配置 PAM 這樣就只能檢查令牌 谷歌的Authenticator.
當用戶連接時,會發生以下情況:
- Freeradius 檢查用戶是否在域中以及某個組中,如果成功,則檢查 OTP 令牌。
一切看起來都很好,直到我想到“如何為 300 多個用戶註冊 OTP?”的那一刻。
用戶必須使用以下命令登錄服務器 FreeRADIUS的 並從您的帳戶下運行應用程序 Google身份驗證器,這將為用戶生成應用程序的二維碼。 這就是幫助發揮作用的地方。 謝麗娜盒子 結合 .bash_配置文件.
[root@freeradius ~]# yum install -y shellinabox
守護進程配置文件位於 /etc/sysconfig/shellinabox.
我在那裡指定了端口 443,您可以指定您的證書。
[root@freeradius ~]#systemctl enable --now shellinaboxd
用戶只需點擊鏈接,輸入域名積分並收到申請的二維碼。
算法如下:
- 用戶通過瀏覽器登錄機器。
- 是否檢查域用戶。 如果不是,則不採取任何行動。
- 如果用戶是域用戶,則會檢查管理員組中的成員身份。
- 如果不是管理員,它會檢查是否配置了 Google 身份驗證器。 如果沒有,則會生成二維碼並退出用戶。
- 如果不是管理員並且配置了 Google 身份驗證器,則只需註銷即可。
- 如果是管理員,請再次檢查 Google Authenticator。 如果未配置,則會生成二維碼。
所有邏輯都是使用完成的 /etc/skel/.bash_profile.
貓 /etc/skel/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
# Make several commands available from user shell
if [[ -z $(id $USER | grep "admins") || -z $(cat /etc/passwd | grep $USER) ]]
then
[[ ! -d $HOME/bin ]] && mkdir $HOME/bin
[[ ! -f $HOME/bin/id ]] && ln -s /usr/bin/id $HOME/bin/id
[[ ! -f $HOME/bin/google-auth ]] && ln -s /usr/bin/google-authenticator $HOME/bin/google-auth
[[ ! -f $HOME/bin/grep ]] && ln -s /usr/bin/grep $HOME/bin/grep
[[ ! -f $HOME/bin/figlet ]] && ln -s /usr/bin/figlet $HOME/bin/figlet
[[ ! -f $HOME/bin/rebel.tlf ]] && ln -s /usr/share/figlet/rebel.tlf $HOME/bin/rebel.tlf
[[ ! -f $HOME/bin/sleep ]] && ln -s /usr/bin/sleep $HOME/bin/sleep
# Set PATH env to <home user directory>/bin
PATH=$HOME/bin
export PATH
else
PATH=PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
fi
if [[ -n $(id $USER | grep "domain users") ]]
then
if [[ ! -e $HOME/.google_authenticator ]]
then
if [[ -n $(id $USER | grep "admins") ]]
then
figlet -t -f $HOME/bin/rebel.tlf "Welcome to Company GAuth setup portal"
sleep 1.5
echo "Please, run any of these software on your device, where you would like to setup OTP:
Google Autheticator:
AppStore - https://apps.apple.com/us/app/google-authenticator/id388497605
Play Market - https://play.google.com/stor/apps/details?id=com.google.android.apps.authenticator2&hl=en
FreeOTP:
AppStore - https://apps.apple.com/us/app/freeotp-authenticator/id872559395
Play Market - https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp&hl=en
And prepare to scan QR code.
"
sleep 5
google-auth -f -t -w 3 -r 3 -R 30 -d -e 1
echo "Congratulations, now you can use an OTP token from application as a password connecting to VPN."
else
figlet -t -f $HOME/bin/rebel.tlf "Welcome to Company GAuth setup portal"
sleep 1.5
echo "Please, run any of these software on your device, where you would like to setup OTP:
Google Autheticator:
AppStore - https://apps.apple.com/us/app/google-authenticator/id388497605
Play Market - https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en
FreeOTP:
AppStore - https://apps.apple.com/us/app/freeotp-authenticator/id872559395
Play Market - https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp&hl=en
And prepare to scan QR code.
"
sleep 5
google-auth -f -t -w 3 -r 3 -R 30 -d -e 1
echo "Congratulations, now you can use an OTP token from application as a password to VPN."
logout
fi
else
echo "You have already setup a Google Authenticator"
if [[ -z $(id $USER | grep "admins") ]]
then
logout
fi
fi
else
echo "You don't need to set up a Google Authenticator"
fi
加強設置:
- 我們創造 半徑-服務器
- 我們創建必要的組,如有必要,按組進行訪問控制。 群組名稱於 加強 必須與傳入的組匹配 供應商特定屬性 Fortinet 組名稱.
- 編輯必要的 SSL-門戶網站。
- 將組添加到策略中。
該解決方案的優點:
- 可以通過 OTP 進行身份驗證 加強 開源解決方案。
- 用戶通過 VPN 連接時無需輸入域密碼,這在一定程度上簡化了連接過程。 6位密碼比安全策略提供的密碼更容易輸入。 因此,主題為“我無法連接到 VPN”的工單數量減少了。
PS 我們計劃將此解決方案升級為具有質詢響應的成熟雙因素身份驗證。
更新:
正如所承諾的,我將其調整為挑戰-響應選項。
所以:
在文件中 /etc/raddb/sites-enabled/default 部分 授權 如下所示:
authorize {
filter_username
preprocess
auth_log
chap
mschap
suffix
eap {
ok = return
}
files
-sql
#-ldap
expiration
logintime
if (!State) {
if (&User-Password) {
# If !State and User-Password (PAP), then force LDAP:
update control {
Ldap-UserDN := "%{User-Name}"
Auth-Type := LDAP
}
}
else {
reject
}
}
else {
# If State, then proxy request:
group_authorization
}
pap
}
部分 認證 現在看起來像這樣:
authenticate {
Auth-Type PAP {
pap
}
Auth-Type CHAP {
chap
}
Auth-Type MS-CHAP {
mschap
}
mschap
digest
# Attempt authentication with a direct LDAP bind:
Auth-Type LDAP {
ldap
if (ok) {
update reply {
# Create a random State attribute:
State := "%{randstr:aaaaaaaaaaaaaaaa}"
Reply-Message := "Please enter OTP"
}
# Return Access-Challenge:
challenge
}
}
pam
eap
}
現在用戶驗證根據以下算法進行:
- 用戶在 VPN 客戶端中輸入域信用。
- Freeradius檢查賬號和密碼的有效性
- 如果密碼正確,則會發送令牌請求。
- 令牌正在驗證中。
- 利潤)。
來源: www.habr.com