Skip to content

Built-in Microsoft Authentication extension fails behind a proxy #226662

@mikejancar

Description

@mikejancar

Does this issue occur when all extensions are disabled?: Yes/No

No. The issue occurs in a built-in extension so extensions need to be enabled to see the issue.

Version: 1.93.0-insider (Universal)
Commit: e81acea
Date: 2024-08-26T05:04:02.640Z
Electron: 30.3.1
ElectronBuildId: 9960165
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0

Steps to Reproduce:

  1. Use VS Code behind a proxy server
  2. Try and make a call to the getSession function from the authentication package included with VS Code similar to the one below.
const session: Session = await authentication.getSession(
      'microsoft',
      [
        'VSCODE_CLIENT_ID:[REMOVED]',
        'VSCODE_TENANT:[REMOVED]',
        'offline_access',
        'https://graph.microsoft.com/User.Read',
      ],
      { createIfNone: true }
    );

After the changes listed in this PR, we began seeing failures from the Microsoft Authentication extension with the following log entries at startup.

2024-08-26 14:03:23.093 [info] Getting sessions for all scopes...
2024-08-26 14:03:23.093 [info] Got 0 sessions for all scopes...
2024-08-26 14:03:23.100 [info]  for undefined
2024-08-26 14:03:23.100 [info] [VSCODE_CLIENT_ID:[REMOVED] VSCODE_TENANT:[REMOVED] email https://graph.microsoft.com/User.Read offline_access openid profile] Got 0 sessions
2024-08-26 14:03:25.503 [info]  for undefined
2024-08-26 14:04:38.407 [error] [VSCODE_CLIENT_ID:[REMOVED] VSCODE_TENANT:[REMOVED] email https://graph.microsoft.com/User.Read offline_access openid profile] Fetching token failed: fetch failed
2024-08-26 14:04:38.408 [error] [VSCODE_CLIENT_ID:[REMOVED] VSCODE_TENANT:[REMOVED] email https://graph.microsoft.com/User.Read offline_access openid profile] Error exchanging code for token: Error: Network failure
2024-08-26 14:04:38.408 [error] [VSCODE_CLIENT_ID:[REMOVED] VSCODE_TENANT:[REMOVED] email https://graph.microsoft.com/User.Read offline_access openid profile] Error creating session: Error: Network failure

We rely on that extension to allow another extension we developed internally to authenticate our users. After debugging into the extension source, I found that the issue was originating here.

result = await fetch(endpoint, {

After reading through the previously mentioned pull request, I figured that the call was hanging because the new fetch function was not handling proxy configurations the same way (a common issue in corporate settings). I pulled down VS Code, built from source and tested a change that resolves the issue. I'd like to open a pull request with the fix if you agree that there is a bug in this flow.

System Information

Measurement Value
CPUs Apple M3 Pro (12 x 2400)
GPU Status 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off
Load (avg) 3, 3, 4
Memory (System) 36.00GB (2.65GB free)
Process Argv --crash-reporter-id 44f29cae-ae86-4363-9dbf-d5928fb946e1
Screen Reader no
VM 0%

Metadata

Metadata

Labels

authentication-microsoftIssues with the Microsoft Authentication extensionbugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code InsidersverifiedVerification succeeded

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions