Merge pull request #1241 from Safelite/feature/jzimmerman/INSR-9794
INSR-9794: Added some additional logging
This commit is contained in:
commit
1e408be220
3 changed files with 28 additions and 7 deletions
|
|
@ -10,6 +10,17 @@ import { useMainStore } from '@/store';
|
||||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
import * as clientAuthHelper from '@/helpers/clientauth-helper';
|
import * as clientAuthHelper from '@/helpers/clientauth-helper';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
|
||||||
|
// Stub global logging object to avoid real network calls in tests
|
||||||
|
global.$logger = {
|
||||||
|
logError: jest.fn(),
|
||||||
|
logInfo: jest.fn(),
|
||||||
|
logWarn: jest.fn(),
|
||||||
|
logDebug: jest.fn()
|
||||||
|
};
|
||||||
|
|
||||||
|
global.crypto = crypto;
|
||||||
|
|
||||||
// Mock our module for promises.
|
// Mock our module for promises.
|
||||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,7 @@ export default {
|
||||||
showIssLoadingModal(false);
|
showIssLoadingModal(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate all the ISS Config values from the service call returns.
|
|
||||||
this.populateISSConfigValues(clientData);
|
|
||||||
|
|
||||||
// Session should only be created / validated on successful client tag validation to avoid unnecessary sessions for unauthorized users.
|
|
||||||
await analyticsMixin.methods.validateSession();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check cookie
|
// Check cookie
|
||||||
const issCookie = getISSCookie();
|
const issCookie = getISSCookie();
|
||||||
|
|
@ -119,6 +113,7 @@ export default {
|
||||||
return { isAuthorized: false };
|
return { isAuthorized: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the client tag on the store here so we can use it for logging if need be.
|
||||||
this.mainStore.issConfig.clientTag = clientTag;
|
this.mainStore.issConfig.clientTag = clientTag;
|
||||||
|
|
||||||
const resp = await validateISSClientTag(clientTag);
|
const resp = await validateISSClientTag(clientTag);
|
||||||
|
|
@ -126,6 +121,12 @@ export default {
|
||||||
return { isAuthorized: false };
|
return { isAuthorized: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate all the ISS Config values from the service call returns.
|
||||||
|
this.populateISSConfigValues(resp);
|
||||||
|
|
||||||
|
// Session should only be created / validated on successful client tag validation to avoid unnecessary sessions for unauthorized users.
|
||||||
|
await analyticsMixin.methods.validateSession();
|
||||||
|
|
||||||
let isAuthorized = false;
|
let isAuthorized = false;
|
||||||
let clientData = null;
|
let clientData = null;
|
||||||
const decryptedParams = {};
|
const decryptedParams = {};
|
||||||
|
|
@ -143,6 +144,11 @@ export default {
|
||||||
|
|
||||||
isAuthorized = vsigResp?.valid ?? false;
|
isAuthorized = vsigResp?.valid ?? false;
|
||||||
this.mainStore.issConfig.isAuthenticated = isAuthorized;
|
this.mainStore.issConfig.isAuthenticated = isAuthorized;
|
||||||
|
|
||||||
|
// Log the signature validation failure so we can monitor/alert on it.
|
||||||
|
if ( !isAuthorized ) {
|
||||||
|
global.$logger.logError(`[Entry Page] Client signature validation failed for Client Tag: ${clientTag} - Reason: ${vsigResp?.failureReason ?? ''} - Token: ${token} - Signature: ${signature}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
isAuthorized = true;
|
isAuthorized = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2942,6 +2942,8 @@ export const useMainStore = defineStore({
|
||||||
issConfig.billToAccountNumber = billToInfo.toString();
|
issConfig.billToAccountNumber = billToInfo.toString();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Do not log API call failure here since this is a validation call that can be spammy.
|
||||||
|
// Do not bailout because this is a fatal error here.
|
||||||
async validateClientTag(clientTag) {
|
async validateClientTag(clientTag) {
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.ValidateClientTag.method,
|
method: endpoints.ValidateClientTag.method,
|
||||||
|
|
@ -2958,11 +2960,13 @@ export const useMainStore = defineStore({
|
||||||
signature
|
signature
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Log API call failure so we can monitor / alert on failed signature validations.
|
||||||
|
// Do not bailout because this is a fatal error here.
|
||||||
return await globalMethods.callHttpClient({
|
return await globalMethods.callHttpClient({
|
||||||
method: endpoints.ValidateClientSignature.method,
|
method: endpoints.ValidateClientSignature.method,
|
||||||
endpoint: endpoints.ValidateClientSignature.url,
|
endpoint: endpoints.ValidateClientSignature.url,
|
||||||
payload,
|
payload,
|
||||||
logApiCall: false,
|
logApiCall: true,
|
||||||
bailoutOnError: false
|
bailoutOnError: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue