Open dax-westerman opened 1 year ago
I ended up coding a spot-fix in
node_modules\webgme-engine\src\server\storage\websocket.js
in order to resolve the issue, since the call to parse the cookie was occurring before the check to see if the authentication was enabled.
// Worker commands socket.on('simpleRequest', function (data, callback) { //TODO: parser needs to be moved to common place const parseCookie = str => str .split(';') .map(v => v.split('=')) .reduce((acc, v) => { acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); return acc;}, {}); const cookies = parseCookie(this.handshake.headers.cookie); getUserIdFromToken(socket, data && data.webgmeToken) .then(function (userId) { data.userId = userId; data.socketId = socket.id; if (gmeConfig.authentication.enable === true) { return gmeAuth.regenerateJWToken(data.webgmeToken); } }) .then(function (newToken) { data.webgmeToken = newToken; //TODO this should probably come from authenticator and not the request!!! if (gmeConfig.authentication.enable === true && gmeConfig.authentication.azureActiveDirectory.enable === true) { data.aadToken = cookies[gmeConfig.authentication.azureActiveDirectory.cookieId] || null; } ...
Encapsulated parseCookie
lambda as a closure to use in latter scope.
// Worker commands socket.on('simpleRequest', function (data, callback) { //TODO: parser needs to be moved to common place const parseCookie = str => str .split(';') .map(v => v.split('=')) .reduce((acc, v) => { acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); return acc;}, {}); const cookieRef = this.handshake.headers.cookie; const cookies = () => parseCookie(cookieRef); getUserIdFromToken(socket, data && data.webgmeToken) .then(function (userId) { data.userId = userId; data.socketId = socket.id; if (gmeConfig.authentication.enable === true) { return gmeAuth.regenerateJWToken(data.webgmeToken); } }) .then(function (newToken) { data.webgmeToken = newToken; //TODO this should probably come from authenticator and not the request!!! if (gmeConfig.authentication.enable === true && gmeConfig.authentication.azureActiveDirectory.enable === true) { data.aadToken = cookies()[gmeConfig.authentication.azureActiveDirectory.cookieId] || null; } ...
Assigning, since I'm guessing it's worth knowing where the issue is occurring, since it looks like quick fix, and my code is locally changed.
Found in branch branch: 304-Data-dashboard-e2e-tests
Context
Steps to recreate:
1) Run PlatWright test, "Create new repo (and it shows up)." 2) Results in error