KÄ rÄ«koties, ja divfaktoru autentifikÄcija ir vÄlama, bet nav finanÅ”u lÄ«dzekļu aparatÅ«ras tokeniem, un vispÄr tiek ieteikts turÄties pie labas noskaÅas.
Å is risinÄjums nav nekas pÄrÄk oriÄ£inÄls, drÄ«zÄk tas ir dažÄdu risinÄjumu mikss, atrasts interneta plaÅ”umos.
TÄtad, ir dots
DomÄns Active Directory.
LietotÄji domÄnÄ, kas strÄdÄ caur VPN, kÄ daudzi mÅ«sdienÄs.
VPN vÄrtejas lomÄ ir Fortigate.
Paroles saglabÄÅ”ana VPN klientam ir aizliegta droŔības politikÄ.
Politika Fortinet attiecÄ«bÄ uz savÄm tokenÄm ir mazÄk nekÄ izsalkusi ā bezmaksas tokeni ir pieejami 10 eksemplÄros, pÄrÄjie ā par ļoti dÄrgu cenu. RSASecureID, Duo un tamlÄ«dzÄ«gi netika apskatÄ«ti, jo nepiecieÅ”ams opensource risinÄjums.
IepriekÅ”ÄjÄs prasÄ«bas: hosts *nix ar instalÄtu freeradius, sssd ā iekļauts domÄnÄ, domÄna lietotÄji var droÅ”i autentificÄties uz tÄ.
Papildu pakotnes: shellinabox, figlet, freeeradius-ldap, fonts rebel.tlf no repozitorija .
ManÄ piemÄrÄ ā CentOS 7.8.
Darba loÄ£ika ir tÄda: pieslÄdzoties VPN, lietotÄjam jÄievada domÄna pieteikÅ”anÄs un OTP vietÄ parolÄ.
Servisu konfigurÄcija
No /etc/raddb/radiusd.conf mainÄs tikai lietotÄjs un grupa, ar kuru tie uzsÄk freeradius, jo serviss radiusd jÄspÄj lasÄ«t failus visÄs apakÅ”direktorijÄs /home/.
user = root
group = root
Lai varÄtu izmantot grupas iestatÄ«jumos Fortigate, jÄnodod Vendor Specific Attribute. Tam nepiecieÅ”ams direktorijÄ raddb/policy.d izveidot failu ar sekojoÅ”u saturu:
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 := "Laipni lÅ«dzam, AdministrÄtora"}
}
}
else {
update reply {
&Reply-Message := "Nav pilnvarots VPN"
}
reject
}
}
PÄc freeradius-ldap instalÄÅ”anas direktorijÄ raddb/mods-available tiek izveidots fails JÄizveido simboliskÄ saite katalogÄ ldap.
raddb/mods-enabled ln -s /etc/raddb/mods-available/ldap /etc/raddb/mods-enabled/ldap.
Es tÄ satura formÄtu Å”ÄdÄ veidÄ:ŠŃŠøŠ²Š¾Š¶Ń ŠµŠ³Š¾ ŃŠ¾Š“ŠµŃŠ¶ŠøŠ¼Š¾Šµ Šŗ ŃŠ°ŠŗŠ¾Š¼Ń виГŃ:
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'
}
} Failos raddb/sites-enabled/default un raddb/sites-enabled/inner-tunnel sadaÄ¼Ä authorize pievienoju politikas nosaukumu, kas tiks izmantota ā group_authorization. SvarÄ«gs moments ā politikas nosaukums tiek noteikts nevis pÄc faila nosaukuma katalogÄ policy.d, bet gan ar direktÄ«vu iekÅ” faila pirms izliekuma iekavÄm.
SadaÄ¼Ä authenticate Å”ajos paÅ”os failos ir jÄizkomentÄ rinda pam.
FailÄ clients.conf norakstÄm parametrus, ar kuriem tiks izveidota savienojums Fortigate:
client fortigate {
ipaddr = 192.168.1.200
secret = testing123
require_message_authenticator = no
nas_type = other
}
Moduļa konfigurÄcija 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
PamatÄ iesaistoties varianti freeradius ar google authenticator paredz lietotÄja datu ievadi formÄtÄ: lietotÄjvÄrds/parole+OTP.
IedomÄjoties visu lÄstu daudzumu, kas uzkÅ«los uz galvas, ja tiks izmantots noklusÄjuma saistÄ«jums freeradius ar Google Authenticator, tika nolemts izmantot moduļa konfigurÄciju pam tÄdÄ veidÄ, lai pÄrbaudÄ«tu tikai tokenu Google Authenticator.
LietotÄja pieslÄgÅ”anÄs laikÄ notiek sekojoÅ”ais:
- Freeradius pÄrbauda lietotÄja esamÄ«bu domÄnÄ un noteiktÄ grupÄ, un, ja viss ir kÄrtÄ«bÄ, notiek OTP tokena pÄrbaude.
Viss izskatÄ«jÄs diezgan labi, lÄ«dz es nepamanÄ«ju "KÄ reÄ£istrÄt OTP vairÄk nekÄ 300 lietotÄjiem?"
LietotÄjam jÄielogojas serverÄ« no freeradius un no savas lietotÄja konta un jÄpalaiž Google authenticator, kas Ä£enerÄs QR kodu lietotÄjam. Å eit noder shellinabox kombinÄcijÄ ar .bash_profile.
[root@freeradius ~]# yum install -y shellinabox
DemonÄ konfigurÄcijas fails atrodas /etc/sysconfig/shellinabox.
Es tur norÄdu portu 443 un varu norÄdÄ«t savu sertifikÄtu.
[root@freeradius ~]#systemctl enable --now shellinaboxdLietotÄjam paliek tikai jÄapmeklÄ saite, jÄievada domÄna akreditÄ«vi un jÄsaÅem QR kods lietotÄjam.
Algoritms ir Å”Äds:
- LietotÄjs pieslÄdzas maŔīnai caur pÄrlÅ«ku.
- Tiek pÄrbaudÄ«ts, vai lietotÄjs ir domÄna lietotÄjs. Ja nÄ, tad nekÄdi pasÄkumi netiek veikti.
- Ja, ja lietotÄjs ir domÄna, tiek pÄrbaudÄ«ta piederÄ«ba administratoru grupai.
- Ja nav administrators, tiek pÄrbaudÄ«ts, vai ir iestatÄ«ts Google Authenticator. Ja nav, tad tiek Ä£enerÄts QR kods un lietotÄjs tiek izrakstÄ«ts.
- Ja nav administrators un Google Authenticator ir iestatÄ«ts, tad vienkÄrÅ”i tiek izrakstÄ«ts.
- Ja ir administrators, tad atkal tiek pÄrbaudÄ«ts Google Authenticator. Ja nav iestatÄ«ts, tad tiek Ä£enerÄts QR kods.
Visa loģika tiek veikta, izmantojot /etc/skel/.bash_profile.
cat /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 konfigurÄcija:
- Izveidojam Radius-serveris

- Izveidojam nepiecieÅ”amÄs grupas, ja ir nepiecieÅ”ama piekļuves ierobežoÅ”ana grupÄm. Grupas nosaukumam Fortigate jÄatbilst grupai, kas tiek nodota Vendor Specific Attribute Fortinet-Group-Name.

- RediÄ£Äjam nepiecieÅ”amos SSL-portÄlus.

- Pievienojam grupas politikÄm.

Å Ä« risinÄjuma priekÅ”rocÄ«bas:
- Ir iespÄja autentificÄties, izmantojot OTP uz Fortigate atvÄrto avotu risinÄjumu.
- IzslÄdzam domÄna parolÄ ievadi lietotÄjam, pieslÄdzoties VPN, kas nedaudz vienkÄrÅ”o pieslÄgÅ”anÄs procesu. SeÅ”ciparu paroli ir vieglÄk ievadÄ«t nekÄ to, kas paredzÄta droŔības politikÄ. TÄ rezultÄtÄ samazinÄs biļeÅ”u skaits ar tÄmu: "Nevaru pieslÄgties VPN".
P.S. PlÄnos ir uzlabot Å”o risinÄjumu lÄ«dz pilnvÄrtÄ«gai divu faktoru autentifikÄcijai ar challenge-response.
AtjauninÄjums:
KÄ solÄ«ts, es to uzlabojusi lÄ«dz variantam ar challenge-response.
TÄtad:
FailÄ /etc/raddb/sites-enabled/default sekcija authorize izskatÄs Å”Ädi:
authorize {
filter_username
preprocess
auth_log
chap
mschap
suffix
eap {
ok = return
}
files
-sql
#-ldap
expiration
logintime
if (!State) {
if (&User-Password) {
# Ja !State un lietotÄja parole (PAP), tad piespiežam LDAP:
update control {
Ldap-UserDN := "%{User-Name}"
Auth-Type := LDAP
}
}
else {
reject
}
}
else {
# Ja State, tad proksÄ pieprasÄ«jums:
group_authorization
}
pap
}
Sekcija authenticate tagad izskatÄs Å”Ädi:
authenticate {
Auth-Type PAP {
pap
}
Auth-Type CHAP {
chap
}
Auth-Type MS-CHAP {
mschap
}
mschap
digest
# CenÅ”amies autentificÄties, izmantojot tieÅ”o LDAP piesaisti:
Auth-Type LDAP {
ldap
if (ok) {
update reply {
# Izveidojam nejauŔu State atribūtu:
State := "%{randstr:aaaaaaaaaaaaaaaa}"
Reply-Message := "Lūdzu, ievadiet OTP"
}
# Atgriežam Access-Challenge:
challenge
}
}
pam
eap
}
Tagad lietotÄja pÄrbaude notiek pÄc Å”Äda algoritma:
- LietotÄjs ievada domÄna akreditÄcijas datus VPN klientÄ.
- Freeradius pÄrbauda konta un paroles derÄ«gumu.
- Ja parole ir pareiza, tad tiek nosūtīta pieprasījums par tokenu.
- Notiek tokena pÄrbaude.
- Profits).
Avots: habr.com




