Skip to content

Commit

Permalink
Set windows auth headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Dec 27, 2024
1 parent fd89a70 commit f11732c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/connection-treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class ConnectionTreeViewProvider implements vscode.TreeDataProvider<vscod
name: "Default",
appToken: settings.appToken,
url: settings.url,
allowInvalidCertificate: false
allowInvalidCertificate: false,
windowsAuth: false
}, !connectionName || connectionName === 'Default'))
}

Expand Down
1 change: 1 addition & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IConnection {
appToken: string;
url: string;
allowInvalidCertificate: boolean;
windowsAuth: boolean;
}

export function load(): ISettings {
Expand Down
19 changes: 14 additions & 5 deletions src/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class Universal {
appToken = connection.appToken;
url = connection.url;
rejectUnauthorized = !connection.allowInvalidCertificate;
windowsAuth = connection.windowsAuth;
}
}

Expand All @@ -47,15 +48,23 @@ export class Universal {
rejectUnauthorized
});

const headers = {
'Content-Type': contentType
} as any;

if (windowsAuth) {
headers['X-Windows-Auth'] = '';
} else {
headers['Authorization'] = `Bearer ${appToken}`;
};

return axios({
url: `${url}${path}`,
method,
headers: {
authorization: windowsAuth ? null : `Bearer ${appToken}`,
'Content-Type': contentType
},
headers: headers,
data: data,
httpsAgent: agent
httpsAgent: agent,
withCredentials: windowsAuth
});
}

Expand Down

0 comments on commit f11732c

Please sign in to comment.