| Conditions | 7 |
| Paths | 6 |
| Total Lines | 29 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 28.6715 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | 2 | public function before(HttpGetRequest $req) |
|
| 31 | { |
||
| 32 | 2 | if (!$req->username || !$req->password) { |
|
| 33 | 2 | $req->username = null; |
|
| 34 | 2 | $req->password = null; |
|
| 35 | 2 | return; |
|
| 36 | } |
||
| 37 | |||
| 38 | switch ($req->special) { |
||
| 39 | case 'github': |
||
| 40 | if ($req->password === 'x-oauth-basic') { |
||
| 41 | $req->query['access_token'] = $req->username; |
||
| 42 | // forbid basic-auth |
||
| 43 | $req->username = null; |
||
| 44 | $req->password = null; |
||
| 45 | return; |
||
| 46 | } |
||
| 47 | break; |
||
| 48 | case 'gitlab': |
||
| 49 | if ($req->password === 'oauth2') { |
||
| 50 | $req->headers[] = 'Authorization: Bearer ' . $req->username; |
||
| 51 | // forbid basic-auth |
||
| 52 | $req->username = null; |
||
| 53 | $req->password = null; |
||
| 54 | return; |
||
| 55 | } |
||
| 56 | break; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 80 |