coder / code-server

VS Code in the browser
https://coder.com
MIT License
68.35k stars 5.6k forks source link

Logout functionality not working as expected #2984

Closed ghost closed 3 years ago

ghost commented 3 years ago

OS/Web Information

Steps to Reproduce

  1. Navigate to url where code-server is running
  2. Sign in
  3. Choose File > Log out

Expected

The page should refresh and you should be on the login page once again

Actual

Page refreshes but you are still logged in

Screenshot

THE EXACT SAME AS AFTER A LOGIN

Notes

This issue can be reproduced in VS Code: Yes/NoCannot test

jsjoeio commented 3 years ago

Hmm...I'm not able to reproduce when running code-server locally off main.

https://user-images.githubusercontent.com/3806031/112687253-76f2cf80-8e34-11eb-9f02-72497d749871.mov

I will investigate further.

jsjoeio commented 3 years ago

I installed 3.9.2 using yarn global add code-server and could not reproduce.

https://user-images.githubusercontent.com/3806031/112701203-40757e80-8e4d-11eb-975a-51d3840d5032.mov

How are you starting code-server? Do you have a password set or are you running with --auth none? (Apologies if that's a silly question)

jsjoeio commented 3 years ago

And can you check the browser logs after you hit Log out? There might be something there too

ghost commented 3 years ago

I installed 3.9.2 using yarn global add code-server and could not reproduce.

Screen.Recording.2021-03-26.at.4.01.42.PM.mov How are you starting code-server? Do you have a password set or are you running with --auth none? (Apologies if that's a silly question)

I have the HASHED_PASSWORD env var set. Here are the devtools logs after the refresh:

[Deprecation] ::-webkit-details-marker pseudo element selector is deprecated. Please use ::marker instead. See https://chromestatus.com/feature/6730096436051968 for more details.
register.ts:14 [Service Worker] registered
DevTools failed to load SourceMap: Could not load content for https://MYRAILWAYPROJECTNAME-development.up.railway.app/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/dist/pages/pages/vscode.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
(index):1 Site cannot be installed: Page does not work offline. Starting in Chrome 93, the installability criteria is changing, and this site will not be installable. See https://goo.gle/improved-pwa-offline-detection for more information.
webWorkerExtensionHost.ts:125 The web worker extension host is started without an iframe sandbox!
start @ webWorkerExtensionHost.ts:125
Kn @ extensionHostManager.ts:67
_createInstance @ instantiationService.ts:110
createInstance @ instantiationService.ts:76
(anonymous) @ abstractExtensionService.ts:447
_startExtensionHosts @ abstractExtensionService.ts:446
_initialize @ abstractExtensionService.ts:411
(anonymous) @ extensionService.ts:74
Promise.then (async)
Xs @ extensionService.ts:74
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
get @ instantiationService.ts:54
initLayout @ layout.ts:255
(anonymous) @ workbench.ts:137
invokeFunction @ instantiationService.ts:61
startup @ workbench.ts:130
open @ web.main.ts:95
async function (async)
open @ web.main.ts:83
Se @ web.main.ts:359
g @ workbench.web.api.ts:498
(anonymous) @ workbench.ts:498
(anonymous) @ workbench.ts:505
r._invokeFactory @ loader.js:1114
r.complete @ loader.js:1124
r._onModuleComplete @ loader.js:1750
r._onModuleComplete @ loader.js:1762
r._resolve @ loader.js:1710
r.defineModule @ loader.js:1353
o @ loader.js:1638
v @ loader.js:2145
r._invokeFactory @ loader.js:1114
r.complete @ loader.js:1124
r._onModuleComplete @ loader.js:1750
r._onModuleComplete @ loader.js:1762
r._resolve @ loader.js:1710
r.defineModule @ loader.js:1353
p @ loader.js:1800
(anonymous) @ workbench.nls.js:7
abstractExtensionService.ts:846 Extension 'GitHub.vscode-pull-request-github' uses PROPOSED API which is subject to change and removal without notice.
updateEnableProposedApi @ abstractExtensionService.ts:846
_checkEnableProposedApi @ abstractExtensionService.ts:584
_checkEnabledAndProposedAPI @ abstractExtensionService.ts:590
_scanAndHandleExtensions @ extensionService.ts:182
async function (async)
_scanAndHandleExtensions @ extensionService.ts:176
_initialize @ abstractExtensionService.ts:412
(anonymous) @ extensionService.ts:74
Promise.then (async)
Xs @ extensionService.ts:74
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
get @ instantiationService.ts:54
initLayout @ layout.ts:255
(anonymous) @ workbench.ts:137
invokeFunction @ instantiationService.ts:61
startup @ workbench.ts:130
open @ web.main.ts:95
async function (async)
open @ web.main.ts:83
Se @ web.main.ts:359
g @ workbench.web.api.ts:498
(anonymous) @ workbench.ts:498
(anonymous) @ workbench.ts:505
r._invokeFactory @ loader.js:1114
r.complete @ loader.js:1124
r._onModuleComplete @ loader.js:1750
r._onModuleComplete @ loader.js:1762
r._resolve @ loader.js:1710
r.defineModule @ loader.js:1353
o @ loader.js:1638
v @ loader.js:2145
r._invokeFactory @ loader.js:1114
r.complete @ loader.js:1124
r._onModuleComplete @ loader.js:1750
r._onModuleComplete @ loader.js:1762
r._resolve @ loader.js:1710
r.defineModule @ loader.js:1353
p @ loader.js:1800
(anonymous) @ workbench.nls.js:7
console.ts:137 [Extension Host] filesize is active
ismail commented 3 years ago

FWIW I can also reproduce with 3.9.2, also using hashed-password (in config).

jsjoeio commented 3 years ago

Interesting... Maybe it's with the way we store/clear the hashed password 🤔

Thanks for reporting as well @ismail! @AurangAsif sorry, I should have been more specific. Can you post the browser logs? Wondering if we're seeing any errors there related to Log out

ghost commented 3 years ago

Interesting... Maybe it's with the way we store/clear the hashed password 🤔

Thanks for reporting as well @ismail! @AurangAsif sorry, I should have been more specific. Can you post the browser logs? Wondering if we're seeing any errors there related to Log out

By browser logs do you mean Chrome logs, code-server logs or something else?

jsjoeio commented 3 years ago

Chrome logs, exactly! Sorry, I need to work on being more specific as you can see 😅

ismail commented 3 years ago

Here is what I see in the console just after clicking logout:

   INFO Logging out of code-server log.ts:284
   INFO Removing cookie under key log.ts:284
   INFO [lifecycle] onBeforeUnload triggered
   ERR Method not implemented.: Error: Method not implemented.
    at C.setTerminalLayoutInfo (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:950:18444)
    at w._onWillShutdown (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:2741:8425)
    at https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:2741:1969
    at l.fire (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:57:1836)
    at y.doShutdown (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:1713:2673)
    at y.onBeforeUnload (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:1713:1982)
    at https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:1713:1750
    at R._actionCallback (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:1768:5770)
    at R.run (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:171:30024)
    at k.runAction (https://server.url/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:171:30556)
Navigated to https://server.url/
jsjoeio commented 3 years ago

For whoever picks this up, some notes:

  1. re-calculate domain
  2. if cookie is key set again as-is but append expiration
  3. do it from server-side
  4. set path the same as well (probably needs to be sent from browser)

Could possible redirect to ./logout/?path=/bla or do a POST. Then on the logout route we set it just like we do in the login route.

Food for thought.