如果双因素身份验证既可取又棘手,但没有钱购买硬件令牌,而且一般来说它们可以保持良好的心情,该怎么办?
该解决方案并不是超级原创,而是在互联网上找到的不同解决方案的混合。
所以给出
域名 活动目录.
域用户通过 VPN 工作,就像当今的许多用户一样。
充当 VPN 网关 飞塔.
安全策略禁止保存 VPN 客户端的密码。
政治 Fortinet公司 就您自己的代币而言,您不能将其称为低于 zhlob - 有多达 10 个免费代币,其余的 - 以非常不合规的价格。 我没有考虑RSASecureID、Duo之类的,因为我想要开源。
先决条件: 主持人 * nix中 与既定的 FreeRADIUS的, 固态硬盘 - 输入域,域用户可以轻松地在其上进行身份验证。
附加套餐: 贝壳盒, 无花果, freeradius LDAP, 字体 反叛者.tlf 从存储库
在我的示例中 - CentOS 7.8。
工作逻辑应该如下:连接到 VPN 时,用户必须输入域登录名和 OTP,而不是密码。
服务设置
В /etc/raddb/radiusd.conf 仅代表其启动的用户和组 FreeRADIUS的,自从服务 半径 应该能够读取所有子目录中的文件 / home /.
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的 с 谷歌身份验证,决定使用模块配置 PAM 这样就只能检查令牌 谷歌身份验证.
当用户连接时,会发生以下情况:
- 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检查账号和密码的有效性
- 如果密码正确,则会发送令牌请求。
- 令牌正在验证中。
- 利润)。
来源: habr.com