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