Skip to content

Commit

Permalink
Fixes issue with failed silent auth
Browse files Browse the repository at this point in the history
Batch Explorer would not start when an exception is thrown during silent auth that isn't an authentication error.
  • Loading branch information
gingi committed Apr 28, 2022
1 parent 319574c commit d74c92a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/client/core/aad/auth-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,28 @@ describe("AuthProvider", () => {
expectRetryable(["50071", "50133"], false); // One retryable, one not

});

it("shouldn't fail with non-auth exception", async () => {
spyOn<any>(authProvider, "_createClient").and.callFake(tenantId => {
const spy = makeClientApplicationSpy();
returnToken(spy.acquireTokenByCode, `${tenantId}-token`);
return spy;
});
const authCodeSpy =
jasmine.createSpy("authCodeCallback").and.returnValues(
Promise.reject(new Error("Non-auth error")),
);

try {
await authProvider.getToken({
tenantId: "tenant1",
resourceURI: "resourceURI1",
authCodeCallback: authCodeSpy
});
} catch (e) {
fail(`Should not have thrown error: ${e}`);
}
});
});

const makeTokenCacheSpy = () => jasmine.createSpyObj(
Expand Down
4 changes: 3 additions & 1 deletion src/client/core/aad/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export default class AuthProvider {
);
code = await authCodeCallback(url, tenantId, true);
} catch (silentAuthException) {
if (!this._isTenantAuthRetryable(silentAuthException)) {
log.debug(`[${tenantId}] Silent auth failed (${silentAuthException})`)
if (silentAuthException instanceof AuthorizeError &&
!this._isTenantAuthRetryable(silentAuthException)) {
log.warn(`Fatal authentication exception for ${tenantId}:` +
` ${silentAuthException} (non-retryable error code ` +
silentAuthException.errorCodes.join(";") + `)`);
Expand Down

0 comments on commit d74c92a

Please sign in to comment.