我正在创建一个用户应用程序,我通过他们的SOAP API服务连接到服务;我已经能够正常工作,我得到了理想的回应;但在制作应用程序登录框架时,我现在面临安全问题......
我很想创建自己的代码;但是为了安全的开发环境已经是用户登录系统,Laravel也会工作,但我不知道如何将服务连接到SOAP实例,而不是MySQL数据库,这是我目前使用的。
我应该基于SOAP响应在MySQL数据库上创建用户吗?或者有没有办法根据服务的响应创建实例,而不必不断重新调用?
这些是我从服务中收到的回复。
这是我从中收到的 - 请注意用户登录信息是正确的:
Array(
['columnList'] => Array(
[0] => 'Column1',
[1] => 'Column2',
[2] => 'Column3',
[3] => 'Column4',
[4] => 'Column5'
// ... etc
),
['data'] => array(
[0] => array(
[0] => 'Value_1',
[1] => 'Value_2',
[2] => 'Value_3',
[3] => 'Value_4',
[4] => 'Value_5'
// ... etc
),
// if the user has more entries then we it will create more arrays below
)
);
如果用户的信息错误或用户不匹配,我只会收到字符串响应
[string] 'nomatch'
我尝试从服务收到的响应中创建$_SESSION
变量:
函数user_print
是我尝试为该用户创建一个独特的指纹,我可以使用它来提取所有应用程序数据,并将其用作标识符。
public function user_print( $array )
{
if ( is_array( $array ) || is_object( $array ) )
{
// call back to handle function
// cannot use $this since this is in the SONIS class scope
$combine = applicant::handle_obj( $array );
// set session variable to user
$_SESSION['user_print'] = md5 ( $combine['SOC_SEC'] . $combine['OA_PIN'] . $combine['FIRST_NAME'] . $combine['LAST_NAME'] . $combine['E_MAIL'] . $combine['APP_START_DATE'] . $_SERVER['HTTP_USER_AGENT'] );
$_SESSION['userid'] = $combine['SOC_SEC'];
$_SESSION['email'] = $combine['E_MAIL'];
$user_browser = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['login_string'] = hash ( 'sha512', $combine['OA_PIN'] . $user_browser );
return true;
}
else
{
if ( $array == 'nomatch' )
{
$message = array(
'is_error' => 'warning',
'message' => 'User information is incorrect.'
);
return $message;
exit;
}
else
{
$message = array(
'is_error' => 'danger',
'message' => 'We just hit a snag...'
);
return $message;
exit;
}
}
}
为了处理我服务的响应,我创建了一个独特的功能:
private function handle_obj( $array )
{
// if it's an object we treat it as such
if ( is_object( $array ) )
{
// reduce array->data to simpler format
$call_data = array_reduce( $array->data, 'array_merge', [] );
// combine both arrays
$combine = array_combine ( $array->columnList, $call_data );
}
// if it's not an object, treat it as array.
else if ( is_array( $array ) )
{
// reduce array->data to simpler format
$call_data = array_reduce( $array['data'], 'array_merge', [] );
// combine both arrays
$combine = array_combine ( $call['columnList'], $call_data );
}
else
{
$combine = '';
}
return $combine;
}
我可以让代码工作;但我担心这不是解决这个问题最安全,最合适的方式。
我将不胜感激任何帮助!
谢谢