1
0
mirror of https://github.com/dap-ps/discover.git synced 2025-01-31 03:26:13 +00:00
discover/back-end/utils/authorization-utils.js
2019-06-03 21:01:42 +03:00

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]
}
}
}