Skip to content

Commit

Permalink
Disable logging for kube probe and health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepdeJong committed Sep 7, 2023
1 parent 483b652 commit 3fb3b22
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/plugins/authiapconnect2/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ private function getIapToken()
if ($devToken) {
return $devToken;
}

if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'GoogleHC') !== false) {
return 'GoogleHC';
}

if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'kube-probe') !== false) {
return 'kube-probe';
}

throw new Exception('No token found');
}

Expand All @@ -47,14 +56,14 @@ public function trustExternal($user, $pass, $sticky = false)
global $USERINFO;

$sticky ? $sticky = true : $sticky = false; //sanity check
if (!empty($_SESSION[DOKU_COOKIE]['auth']['info'])) {
$USERINFO['name'] = $_SESSION[DOKU_COOKIE]['auth']['info']['name'];
$USERINFO['mail'] = $_SESSION[DOKU_COOKIE]['auth']['info']['mail'];
$USERINFO['grps'] = $_SESSION[DOKU_COOKIE]['auth']['info']['grps'];
$_SERVER['REMOTE_USER'] = $_SESSION[DOKU_COOKIE]['auth']['user'];
return true;
}

if (!empty($_SESSION[DOKU_COOKIE]['auth']['info'])) {
$USERINFO['name'] = $_SESSION[DOKU_COOKIE]['auth']['info']['name'];
$USERINFO['mail'] = $_SESSION[DOKU_COOKIE]['auth']['info']['mail'];
$USERINFO['grps'] = $_SESSION[DOKU_COOKIE]['auth']['info']['grps'];
$_SERVER['REMOTE_USER'] = $_SESSION[DOKU_COOKIE]['auth']['user'];
return true;
}

$token = $this->getIapToken();

Expand All @@ -63,16 +72,16 @@ public function trustExternal($user, $pass, $sticky = false)
$USERINFO = [
'name' => $data['gcip']['name'],
'mail' => $data['gcip']['email'],
'grps' => array_merge(explode(',',$data['gcip']['groups']), ['user'])
'grps' => array_merge(explode(',', $data['gcip']['groups']), ['user'])
];

$_SERVER['REMOTE_USER'] = $USERINFO['name'];
$_SESSION[DOKU_COOKIE]['auth']['user'] = $USERINFO['name'];
$_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;

return true;
} catch (Exception $e) {
return false;
}
}
}
}

0 comments on commit 3fb3b22

Please sign in to comment.