mirror of
https://github.com/dap-ps/discover.git
synced 2025-01-31 11:35:18 +00:00
16 lines
455 B
JavaScript
16 lines
455 B
JavaScript
module.exports = {
|
|
parseBasicAuthorization: function (authHeader) {
|
|
if (!authHeader) {
|
|
throw new Error('Authorization not provided');
|
|
}
|
|
|
|
let authString = authHeader.split(/\s/)[1];
|
|
let stringifiedAuth = Buffer.from(authString, 'base64').toString();
|
|
let authParts = stringifiedAuth.split(':');
|
|
|
|
return {
|
|
username: authParts[0],
|
|
password: authParts[1]
|
|
}
|
|
}
|
|
} |