Skip to content

Commit

Permalink
Plumb error through to auth page (#221511)
Browse files Browse the repository at this point in the history
plumb error through to auth page
  • Loading branch information
TylerLeonhardt authored Jul 11, 2024
1 parent d778608 commit 649bcae
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions extensions/microsoft-authentication/src/node/authServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,29 @@ export class LoopbackAuthServer implements ILoopbackServer {
const code = reqUrl.searchParams.get('code') ?? undefined;
const state = reqUrl.searchParams.get('state') ?? undefined;
const nonce = (reqUrl.searchParams.get('nonce') ?? '').replace(/ /g, '+');
const error = reqUrl.searchParams.get('error') ?? undefined;
if (error) {
res.writeHead(302, { location: `/?error=${reqUrl.searchParams.get('error_description')}` });
res.end();
deferred.reject(new Error(error));
break;
}
if (!code || !state || !nonce) {
res.writeHead(400);
res.end();
return;
break;
}
if (this.state !== state) {
res.writeHead(302, { location: `/?error=${encodeURIComponent('State does not match.')}` });
res.end();
throw new Error('State does not match.');
deferred.reject(new Error('State does not match.'));
break;
}
if (this.nonce !== nonce) {
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}` });
res.end();
throw new Error('Nonce does not match.');
deferred.reject(new Error('Nonce does not match.'));
break;
}
deferred.resolve({ code, state });
res.writeHead(302, { location: '/' });
Expand Down

0 comments on commit 649bcae

Please sign in to comment.