(auth)
| 449 | } |
| 450 | |
| 451 | function parseBasicAuth(auth) { |
| 452 | // auth is like `Basic Y2hhcmxlczoxMjM0NQ==` |
| 453 | var tmp = auth.split(' '); |
| 454 | |
| 455 | var buf = Buffer.from(tmp[1], 'base64'); |
| 456 | var plain = buf.toString(); |
| 457 | |
| 458 | var creds = plain.split(':'); |
| 459 | return { |
| 460 | username: creds[0], |
| 461 | password: creds[1] |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | function sendBasicAuthResponse(response) { |
| 466 | response.writeHead(401, { |