/ Backend / utils / authorization-utils.js
authorization-utils.js
 1  module.exports = {
 2      parseBasicAuthorization: function (authHeader) {
 3          if (!authHeader) {
 4              throw new Error('Authorization not provided');
 5          }
 6  
 7          let authString = authHeader.split(/\s/)[1];
 8          let stringifiedAuth = Buffer.from(authString, 'base64').toString();
 9          let authParts = stringifiedAuth.split(':');
10  
11          return {
12              username: authParts[0],
13              password: authParts[1]
14          }
15      }
16  }