- send auth session

- prepare credentials from auth session
This commit is contained in:
Sandeep Somavarapu
2020-09-13 01:56:02 +02:00
parent 59023b549c
commit 52bdeff880
4 changed files with 67 additions and 51 deletions

View File

@@ -369,32 +369,17 @@ async function handleRoot(req, res) {
webConfigJSON._wrapWebWorkerExtHostInIframe = true;
}
const credentials = [];
if (args['github-auth']) {
const sessionId = uuid.v4();
credentials.push({
service: 'code-oss.login',
account: 'account',
password: JSON.stringify({
id: sessionId,
providerId: 'github',
accessToken: args['github-auth']
})
}, {
service: 'code-oss-github.login',
account: 'account',
password: JSON.stringify([{
id: sessionId,
scopes: ['user:email'],
accessToken: args['github-auth']
}])
});
}
const authSessionInfo = args['github-auth'] ? {
id: uuid.v4(),
providerId: 'github',
accessToken: args['github-auth'],
scopes: [['user:email'], ['repo']]
} : undefined;
const data = (await readFile(WEB_MAIN)).toString()
.replace('{{WORKBENCH_WEB_CONFIGURATION}}', () => escapeAttribute(JSON.stringify(webConfigJSON))) // use a replace function to avoid that regexp replace patterns ($&, $0, ...) are applied
.replace('{{WORKBENCH_BUILTIN_EXTENSIONS}}', () => escapeAttribute(JSON.stringify(dedupedBuiltInExtensions)))
.replace('{{WORKBENCH_CREDENTIALS}}', () => escapeAttribute(JSON.stringify(credentials)))
.replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '')
.replace('{{WEBVIEW_ENDPOINT}}', '');