mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-01-20 10:52:15 +01:00
Added possibility to use custom fields in logging module. Also added client IP and otp in verify and sync logs.
This commit is contained in:
parent
433c82cce7
commit
c2245924cf
@ -6,14 +6,26 @@ class Log
|
||||
function __construct($name='ykval')
|
||||
{
|
||||
$this->name=$name;
|
||||
$this->fields=array();
|
||||
}
|
||||
|
||||
function addField($name, $value)
|
||||
{
|
||||
$this->fields[$name]=$value;
|
||||
}
|
||||
|
||||
function log($priority, $message, $arr=null){
|
||||
if (is_array($arr)) {
|
||||
foreach($arr as $key=>$value){
|
||||
$message.=" $key=$value ";
|
||||
}
|
||||
}
|
||||
syslog($priority, $this->name . ':' . $message);
|
||||
# Add fields
|
||||
$msg_fields = "";
|
||||
foreach ($this->fields as $field=>$value) {
|
||||
$mes_fields .= "[" . $value . "] ";
|
||||
}
|
||||
syslog($priority, $this->name . ':' . $msg_fields . $message);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,9 +8,12 @@ $apiKey = '';
|
||||
header("content-type: text/plain");
|
||||
|
||||
$myLog = new Log('ykval-sync');
|
||||
$myLog->addField('ip', $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
$myLog->log(LOG_INFO, "Request: " . $_SERVER['QUERY_STRING']);
|
||||
|
||||
$sync = new SyncLib('ykval-sync:synclib');
|
||||
$sync->myLog->addField('ip', $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if (! $sync->isConnected()) {
|
||||
sendResp(S_BACKEND_ERROR, $apiKey);
|
||||
@ -67,6 +70,12 @@ foreach ($syncParams as $param=>$value) {
|
||||
}
|
||||
$myLog->log(LOG_INFO, $tmp_log);
|
||||
|
||||
#
|
||||
# At this point we should have to otp so let's add it to the logging module
|
||||
#
|
||||
$myLog->addField('otp', $syncParams['otp']);
|
||||
$sync->myLog->addField('otp', $syncParams['otp']);
|
||||
|
||||
#
|
||||
# Verify correctness of input parameters
|
||||
#
|
||||
|
@ -8,6 +8,7 @@ $apiKey = '';
|
||||
header("content-type: text/plain");
|
||||
|
||||
$myLog = new Log('ykval-verify');
|
||||
$myLog->addField('ip', $_SERVER['REMOTE_ADDR']);
|
||||
$myLog->log(LOG_INFO, "Request: " . $_SERVER['QUERY_STRING']);
|
||||
|
||||
/* Detect protocol version */
|
||||
@ -20,7 +21,9 @@ $myLog->log(LOG_INFO, "found protocol version " . $protocol_version);
|
||||
|
||||
/* Initialize the sync library. Strive to use this instead of custom DB requests,
|
||||
custom comparisons etc */
|
||||
$sync = new SyncLib();
|
||||
$sync = new SyncLib('ykval-verify:synclib');
|
||||
$sync->myLog->addField('ip', $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if (! $sync->isConnected()) {
|
||||
sendResp(S_BACKEND_ERROR, $apiKey);
|
||||
exit;
|
||||
@ -34,6 +37,11 @@ $client = getHttpVal('id', 0);
|
||||
$otp = getHttpVal('otp', '');
|
||||
$otp = strtolower($otp);
|
||||
$timestamp = getHttpVal('timestamp', 0);
|
||||
|
||||
/* We have the OTP now, so let's add it to the logging */
|
||||
$myLog->addField('otp', $otp);
|
||||
$sync->myLog->addField('otp', $otp);
|
||||
|
||||
if ($protocol_version>=2.0) {
|
||||
|
||||
$sl = getHttpVal('sl', '');
|
||||
|
Loading…
x
Reference in New Issue
Block a user