diff --git a/ams-express-shopping/auth/authenticate.js b/ams-express-shopping/auth/authenticate.js index 60b3748..0bc784d 100644 --- a/ams-express-shopping/auth/authenticate.js +++ b/ams-express-shopping/auth/authenticate.js @@ -37,12 +37,13 @@ https://www.npmjs.com/package/@sap/xssec#testing function buildMockAuthMiddleware() { return async function mockAuthentication(req, res, next) { const basicAuthUser = req.headers['authorization']?.split(' ')[1]; - if (!basicAuthUser) { + const user = Buffer.from(basicAuthUser, 'base64').toString().split(':')[0]; + const [username, api] = user.split('|'); + + if (!username) { return res.sendStatus(401); } - const user = Buffer.from(basicAuthUser, 'base64').toString().split(':')[0]; - const [username, api] = user.split('|'); const mockPayload = { app_tid: "default", scim_id: username, diff --git a/ams-express-shopping/service/privileges.js b/ams-express-shopping/service/privileges.js index 907d939..ce15f2f 100644 --- a/ams-express-shopping/service/privileges.js +++ b/ams-express-shopping/service/privileges.js @@ -1,3 +1,5 @@ +const { AMS_AUTHORIZATIONS } = require("@sap/ams"); + /** * Returns the potential privileges of the user to determine which UI elements to show. * @param {import("@sap/ams").AuthorizedRequest} req diff --git a/ams-express-shopping/ui/index.html b/ams-express-shopping/ui/index.html index ec483ef..ef286d9 100644 --- a/ams-express-shopping/ui/index.html +++ b/ams-express-shopping/ui/index.html @@ -16,7 +16,7 @@