简体   繁体   English

验证 PHP SOAP SERVER 中的 WS-security 密码摘要

[英]Verify WS-security password digest in PHP SOAP SERVER

I need to implement WS-Security password digest on PHP-Soap webservice.我需要在 PHP-Soap webservice 上实现 WS-Security 密码摘要。 I looked everywhere on how to do it and I've found nothing.我到处寻找如何做到这一点,但我一无所获。 through trial and error I've found out that PHP Soap server will call a "Secutity" function implemented in Service class where verification will be performed. through trial and error I've found out that PHP Soap server will call a "Secutity" function implemented in Service class where verification will be performed. For now my function looks like this:现在我的 function 看起来像这样:

public function Security($UsernameToken)
{

    $this->log($UsernameToken);
    $loggHelper = [];
    $loggHelper['nonce'] = unpack('H*', base64_decode($UsernameToken->Nonce))[1];
    $loggHelper['created'] = pack('a*', $UsernameToken->Created);
    $loggHelper['password'] = pack('a*', 'test');
    $loggHelper['passhash1'] = base64_encode(pack('H*',sha1($loggHelper['nonce'].$UsernameToken->Created.$loggHelper['password'])));
    $this->log($loggHelper);
    if($UsernameToken->Password==$loggHelper['passhash1'])
        return true;
    else
    {
        return new SoapFault("401", "Prohibited");
    }

}

The problem is, that my Digest is not the same as the password provided by test client (SoapUI)问题是,我的摘要与测试客户端(SoapUI)提供的密码不同

Log output looks like this:日志 output 如下所示:

$UsernameToken = {"Username":"test","Password":"HMxOK\/pg3mOq71N2F5Znb7xDdcw=","Nonce":"BgbT8vrQb\/afX7OC3KPb0Q==","Created":"2020-06-24T07:31:11.731Z"}

$loggerHelper = {"nonce":"0606d3f2fad06ff69f5fb382dca3dbd1","created":"2020-06-24T07:31:11.731Z","password":"test","passhash1":"gJGXpD3yYDmLY6qMhRtKYWr33IA="}

First some remarks:先说几点:

I would suggest to use我建议使用

for encryption, which is contained in PHP itself.用于加密,它包含在 PHP 本身中。

Or you use a framework which handles security under the hood.或者您使用一个框架来处理引擎盖下的安全性。 As an example (but I am not sure) symfony should do this automatically for you - please read more at https://symfony.com/doc/current/controller/soap_web_service.html例如(但我不确定)symfony 应该自动为您执行此操作 - 请在https://symfony.com/doc/current/controller/soap_web_service.ZFC35FDC70D5FCC69D2569883A822E阅读更多内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM