1 | /**
|
2 | * HTTP basic authentication parser.
|
3 | *
|
4 | * @package basic
|
5 | * @author Andrew Sliwinski <andrew@diy.org>
|
6 | */
|
7 |
|
8 | /**
|
9 | * Dependencies
|
10 | */
|
11 |
|
12 | /**
|
13 | * Export
|
14 | */
|
15 | module.exports = function (input) {
|
16 | var token = input.split(/\s+/).pop() || '';
|
17 | var auth = new Buffer(token, 'base64').toString();
|
18 | var parts = auth.split(/:/);
|
19 |
|
20 | return {
|
21 | username: parts[0],
|
22 | password: parts[1]
|
23 | };
|
24 | }; |
\ | No newline at end of file |