Skip to content

Commit 77044e3

Browse files
authored
sessions - specific auth branding for auth redirect (#298277)
1 parent 79d358e commit 77044e3

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

extensions/github-authentication/media/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,17 @@ <h1 class="title">Launching <span class="app-name"></span></h1>
3030
</div>
3131
<script>
3232
const urlParams = new URLSearchParams(window.location.search);
33+
3334
const appName = urlParams.get('app_name');
3435
document.querySelectorAll('.app-name').forEach(e => e.innerText = appName);
3536

37+
if (urlParams.get('app_is_sessions') === 'true') {
38+
const iconImg = document.querySelector('.icon-container img');
39+
if (iconImg) {
40+
iconImg.src = 'sessions-icon.svg';
41+
}
42+
}
43+
3644
// if name contains 'insiders', update filter CSS variables
3745
if (appName.toLowerCase().includes('insiders')) {
3846
document.documentElement.style.setProperty('--vscode-filter-0', 'var(--vscode-insiders-filter-0)');
Lines changed: 24 additions & 0 deletions
Loading

extensions/github-authentication/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
],
2020
"enabledApiProposals": [
2121
"authIssuers",
22-
"authProviderSpecific"
22+
"authProviderSpecific",
23+
"agentSessionsWorkspace"
2324
],
2425
"activationEvents": [],
2526
"capabilities": {

extensions/github-authentication/src/node/authServer.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { URL } from 'url';
77
import * as fs from 'fs';
88
import * as path from 'path';
99
import { randomBytes } from 'crypto';
10-
import { env } from 'vscode';
10+
import { env, workspace } from 'vscode';
1111

1212
function sendFile(res: http.ServerResponse, filepath: string) {
1313
const isSvg = filepath.endsWith('.svg');
@@ -99,13 +99,14 @@ export class LoopbackAuthServer implements ILoopbackServer {
9999
this._resultPromise = new Promise<IOAuthResult>((resolve, reject) => deferred = { resolve, reject });
100100

101101
const appNameQueryParam = `&app_name=${encodeURIComponent(env.appName)}`;
102+
const appIsSessionsQueryParam = workspace.isAgentSessionsWorkspace ? '&app_is_sessions=true' : '';
102103
this._server = http.createServer((req, res) => {
103104
const reqUrl = new URL(req.url!, `http://${req.headers.host}`);
104105
switch (reqUrl.pathname) {
105106
case '/signin': {
106107
const receivedNonce = (reqUrl.searchParams.get('nonce') ?? '').replace(/ /g, '+');
107108
if (receivedNonce !== this.nonce) {
108-
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}${appNameQueryParam}` });
109+
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}${appNameQueryParam}${appIsSessionsQueryParam}` });
109110
res.end();
110111
}
111112
res.writeHead(302, { location: this._startingRedirect.toString() });
@@ -122,20 +123,20 @@ export class LoopbackAuthServer implements ILoopbackServer {
122123
return;
123124
}
124125
if (this.state !== state) {
125-
res.writeHead(302, { location: `/?error=${encodeURIComponent('State does not match.')}${appNameQueryParam}` });
126+
res.writeHead(302, { location: `/?error=${encodeURIComponent('State does not match.')}${appNameQueryParam}${appIsSessionsQueryParam}` });
126127
res.end();
127128
throw new Error('State does not match.');
128129
}
129130
if (this.nonce !== nonce) {
130-
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}${appNameQueryParam}` });
131+
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}${appNameQueryParam}${appIsSessionsQueryParam}` });
131132
res.end();
132133
throw new Error('Nonce does not match.');
133134
}
134135
deferred.resolve({ code, state });
135136
if (isPortable) {
136-
res.writeHead(302, { location: `/?app_name=${encodeURIComponent(env.appName)}` });
137+
res.writeHead(302, { location: `/?app_name=${encodeURIComponent(env.appName)}${appIsSessionsQueryParam}` });
137138
} else {
138-
res.writeHead(302, { location: `/?redirect_uri=${encodeURIComponent(callbackUri)}${appNameQueryParam}` });
139+
res.writeHead(302, { location: `/?redirect_uri=${encodeURIComponent(callbackUri)}${appNameQueryParam}${appIsSessionsQueryParam}` });
139140
}
140141
res.end();
141142
break;

extensions/github-authentication/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"src/**/*",
1515
"../../src/vscode-dts/vscode.d.ts",
1616
"../../src/vscode-dts/vscode.proposed.authIssuers.d.ts",
17-
"../../src/vscode-dts/vscode.proposed.authProviderSpecific.d.ts"
17+
"../../src/vscode-dts/vscode.proposed.authProviderSpecific.d.ts",
18+
"../../src/vscode-dts/vscode.proposed.agentSessionsWorkspace.d.ts"
1819
]
1920
}

0 commit comments

Comments
 (0)