Conditions | 1 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
30 | 1 | public function authenticate(RequestInterface $request) |
|
31 | { |
||
32 | // TODO: generate better nonce? |
||
33 | 1 | $nonce = substr(md5(uniqid(uniqid().'_', true)), 0, 16); |
|
34 | 1 | $created = date('c'); |
|
35 | 1 | $digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password, true)); |
|
36 | |||
37 | 1 | $wsse = sprintf( |
|
38 | 1 | 'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', |
|
39 | 1 | $this->username, |
|
40 | 1 | $digest, |
|
41 | 1 | $nonce, |
|
42 | $created |
||
43 | 1 | ); |
|
44 | |||
45 | return $request |
||
46 | 1 | ->withHeader('Authorization', 'WSSE profile="UsernameToken"') |
|
47 | 1 | ->withHeader('X-WSSE', $wsse) |
|
48 | 1 | ; |
|
49 | } |
||
50 | } |
||
51 |