E si de-faktè otantifikasyon se tou de dezirab ak pike, men pa gen okenn lajan pou marqueur pyès ki nan konpitè ak an jeneral yo ofri yo rete nan yon atitid bon.
Solisyon sa a se pa yon bagay super orijinal, men pito yon melanj de solisyon diferan yo jwenn sou entènèt la.
Se konsa bay
Domèn Anyè aktif.
Itilizatè domèn k ap travay atravè yon VPN, tankou anpil jodi a.
Aji kòm yon pòtay VPN Fortigate.
Sove modpas la pou kliyan VPN a entèdi pa règleman sekirite.
Politik Fortinet an relasyon ak pwòp marqueur ou a, ou pa ka rele li mwens pase yon zhlob - gen otan ke 10 marqueur gratis, rès la - nan yon pri ki pa kosher. Mwen pa t 'konsidere RSASecureID, Duo ak tankou, paske mwen vle sous louvri.
Prekondisyon: lame * Nix ak etabli freeradius, ssd - antre nan domèn nan, itilizatè domèn ka fasilman otantifye sou li.
Pakè adisyonèl: bwat Shellina, figi, freeradius-ldap, font rebèl.tlf soti nan depo a
Nan egzanp mwen an - CentOS 7.8.
Lojik travay la sipoze jan sa a: lè w konekte ak yon VPN, itilizatè a dwe antre nan yon koneksyon domèn ak OTP olye pou yo yon modpas.
Konfigirasyon sèvis yo
В /etc/raddb/radiusd.conf sèlman itilizatè a ak gwoup sou non ki kòmanse freeradius, depi sèvis la reyond ta dwe kapab li fichye nan tout sous-répertoires / lakay /.
user = root
group = root
Pou kapab itilize gwoup yo nan anviwònman yo Fortigate, yo dwe transmèt Atribi espesifik machann. Pou fè sa, nan anyè a raddb/politik.d Mwen kreye yon fichye ak kontni sa a:
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
}
}
Apre enstalasyon freeradius-ldap nan anyè a raddb/mods-disponib dosye a kreye ldap.
Bezwen kreye yon lyen senbolik nan anyè a raddb/mods-pèmèt.
ln -s /etc/raddb/mods-available/ldap /etc/raddb/mods-enabled/ldap
Mwen pote kontni li yo nan fòm sa a:
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'
}
}
Nan dosye raddb/sit-enabled/default и raddb/sit-enabled/inner-tinnel nan seksyon otorize Mwen ajoute non politik yo dwe itilize a - group_authorization. Yon pwen enpòtan - non an nan politik la pa detèmine pa non an nan dosye a nan anyè a politik.d, men pa yon direktiv andedan fichye a anvan atèl boukle yo.
Nan seksyon an otantifye nan dosye yo menm ou bezwen dekomantè liy lan pam.
Nan dosye kliyan.conf preskri paramèt yo ak ki li pral konekte Fortigate:
client fortigate {
ipaddr = 192.168.1.200
secret = testing123
require_message_authenticator = no
nas_type = other
}
Konfigirasyon modil la 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
Opsyon aplikasyon pakèt default freeradius с Google otantifikatè mande itilizatè a antre kalifikasyon yo nan fòma sa a: non itilizatè/modpas+OTP.
Pa imajine kantite madichon ki pral tonbe sou tèt la, nan ka itilize pake a default freeradius с Google Authenticator, li te deside sèvi ak konfigirasyon modil la pam pou sèlman siy a ka tcheke Google Authenticator.
Lè yon itilizatè konekte, bagay sa yo rive:
- Freeradius tcheke si itilizatè a se nan domèn nan ak nan yon gwoup sèten epi, si yo reyisi, tcheke siy OTP la.
Tout bagay te sanble bon ase jiska moman sa a lè mwen te panse "Kijan mwen ka anrejistre OTP pou plis pase 300 itilizatè?"
Itilizatè a dwe konekte ak sèvè a freeradius ak anba kont ou epi kouri aplikasyon an Google Authenticator, ki pral jenere yon kòd QR pou aplikasyon an pou itilizatè a. Sa a se kote èd vini nan. bwat Shellina an konbinezon ak .bash_profile.
[root@freeradius ~]# yum install -y shellinabox
Fichye konfigirasyon demon an sitiye nan /etc/sysconfig/shellinabox.
Mwen presize pò 443 la epi ou ka presize sètifika ou.
[root@freeradius ~]#systemctl enable --now shellinaboxd
Itilizatè a sèlman bezwen swiv lyen an, antre kredi domèn epi resevwa yon kòd QR pou aplikasyon an.
Algoritm lan se jan sa a:
- Itilizatè a konekte nan machin nan atravè yon navigatè.
- Si wi ou non itilizatè a domèn tcheke. Si ou pa, Lè sa a, pa gen okenn aksyon pran.
- Si itilizatè a se yon itilizatè domèn, yo tcheke manm nan gwoup Administratè yo.
- Si se pa yon admin, li tcheke si Google Authenticator configuré. Si ou pa, Lè sa a, yon kòd QR ak dekonekte itilizatè yo pwodwi.
- Si se pa yon admin ak Google Authenticator configuré, Lè sa a, jis dekonekte.
- Si admin, Lè sa a, tcheke Google Authenticator ankò. Si pa konfigirasyon, yon kòd QR pwodwi.
Tout lojik fèt lè l sèvi avèk /etc/skel/.bash_profile.
chat /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
Fortigate konfigirasyon:
- Nou kreye reyon-sèvè
- Nou kreye gwoup ki nesesè yo, si sa nesesè, kontwòl aksè pa gwoup. Non gwoup la sou Fortigate dwe matche ak gwoup ki pase a Atribi espesifik machann Fortinet-Group-Non.
- Modification nesesè Ssl-portals.
- Ajoute gwoup nan règleman yo.
Avantaj ki genyen nan solisyon sa a:
- Li posib otantifye pa OTP sou Fortigate solisyon sous louvri.
- Itilizatè a pa antre nan yon modpas domèn lè w konekte via VPN, ki yon ti jan senplifye pwosesis koneksyon an. Modpas 6 chif la pi fasil pou antre pase sa ki bay règleman sekirite a. Kòm yon rezilta, kantite tikè ki gen sijè a: "Mwen pa ka konekte ak VPN a" diminye.
PS Nou planifye pou amelyore solisyon sa a nan yon otantifikasyon de faktè konplè ak repons defi.
Mete ajou:
Jan te pwomèt la, mwen te ajiste li nan opsyon defi-repons la.
Se konsa,:
Nan dosye /etc/raddb/sites-enabled/default seksyon otorize sanble tankou sa a:
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
}
Seksyon otantifye kounye a sanble sa a:
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
}
Koulye a, verifikasyon itilizatè a fèt dapre algorithm sa a:
- Itilizatè a antre nan kredi domèn nan kliyan VPN la.
- Freeradius tcheke validite kont lan ak modpas
- Si modpas la kòrèk, yo voye yon demann pou yon siy.
- Yo verifye siy la.
- pwofi).
Sous: www.habr.com