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