Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98632

VS Code Extension - Making a Kerberos-authenticated http request

$
0
0

I'm building a vscode extension for internal use. The workflow for this extension is for it to send contents of the file that the user is editing to a REST server for some external validation. This server requires us to authenticate using Kerberos.

This is what I've got so far:

import axios from "axios";
...
let disposable = vscode.commands.registerCommand('extension.validate', () => {
    const editor = vscode.window.activeTextEditor;

    if (editor) {
            const document = editor.document;
            const fullText = document.getText()
            const relativePath = "path/to/file"
            const ROOT_URL = "www.example.com/validate"
            const url = `${ROOT_URL}/${relativePath}`
            console.log(`pushing to ${url}`)

            axios.put(url,
              { fileContents: fullText },
              { withCredentials: true, headers: {"Authorization": "Negotiate"} }
            ).catch(function(err: any) {
            console.log(err)
        }).then(...)
...
}

However, the request is failing with 403s.

Error: Request failed with status code 403
    at createError (/data/home/me/projects/my-extension/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/data/home/me/projects/my-extension/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/data/home/me/projects/my-extension/node_modules/axios/lib/adapters/http.js:236:11)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1092:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Is there a way to ensure that the appropriate kerberos headers are picked up from vscode's environment? Is this possible with another library - I've tried axios, request and whatwg-fetch, though I'm aware the last may not work outside of a browser?


Viewing all articles
Browse latest Browse all 98632

Trending Articles