Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions user_otp/adminSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@
$configOtp[$i]['type']='checkbox';
$configOtp[$i]['default_value']=false; $i++;

$configOtp[$i]['name']='exceptForThisHosts';
$configOtp[$i]['label']='Skip otp for these hosts ( comma separated )';
$configOtp[$i]['type']='text';
$configOtp[$i]['default_value']='localhost'; $i++;

foreach ($allTab as $tab){
foreach ($$tab["arrayConf"] as $input){
switch ($input['type']){
Expand Down
11 changes: 11 additions & 0 deletions user_otp/lib/otp.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ public function checkPassword($uid, $password) {
return $userBackend->checkPassword($uid, $password);
}

$bypass_hosts = array_map('trim', explode(',', OCP\Config::getAppValue('user_otp','exceptForThisHosts',"localhost")));
foreach ($bypass_hosts as &$single_host) {
if ($single_host!=null && isset($_SERVER['REMOTE_ADDR'])) {
OC_Log::write('OC_USER_OTP','Checking \''.$_SERVER['REMOTE_ADDR'].'\' against \''.$single_host.'\'', OC_Log::DEBUG);
if (gethostbyname($single_host) === $_SERVER['REMOTE_ADDR'] ) {
OC_Log::write('OC_USER_OTP','Skipping OTP for '.$uid.' from \''.$single_host.'\' ('.$_SERVER['REMOTE_ADDR'].')', OC_Log::INFO);
return $userBackend->checkPassword($uid, $password);
}
}
}

if(!$this->mOtp->CheckUserExists($uid)){
OC_Log::write('OC_USER_OTP','No OTP for user '.$uid.' use user backend', OC_Log::DEBUG);
return $userBackend->checkPassword($uid, $password);
Expand Down