This commit is contained in:
Jeremy Zimmerman 2023-09-18 18:01:41 -04:00
parent eeed38d588
commit 6ee9223253
6 changed files with 41 additions and 10 deletions

2
package-lock.json generated
View file

@ -35,7 +35,7 @@
"@vue/vue3-jest": "^27.0.0-alpha.1",
"axios-mock-adapter": "^1.21.5",
"babel-jest": "^27.0.6",
"eslint": "8.45.0",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-plugin-import": "2.26.0",

View file

@ -42,7 +42,7 @@
"@vue/vue3-jest": "^27.0.0-alpha.1",
"axios-mock-adapter": "^1.21.5",
"babel-jest": "^27.0.6",
"eslint": "8.45.0",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-plugin-import": "2.26.0",

View file

@ -126,6 +126,10 @@ const endpoints = Object.freeze({
url: '/clientauth/api/v1/clientauth/validate-client-tag',
method: 'GET'
},
ValidateClientSignature: {
url: '/clientauth/api/v1/clientauth/validate-client-signature',
method: 'POST'
},
IsVinbyAddressPermissible: {
url: '/vehicle/api/v1/vehicle/is-vin-by-address-permissible',
method: 'Get'

View file

@ -1,6 +1,6 @@
import { useMainStore } from '@/store';
const validateISSClientTag = (clientTag) => {
export function validateISSClientTag(clientTag) {
const store = useMainStore();
return store.validateClientTag(clientTag)
@ -8,6 +8,14 @@ const validateISSClientTag = (clientTag) => {
(response) => response,
() => null
);
};
}
export default validateISSClientTag;
export function validateISSClientSignature(clientTag, token, signature) {
const store = useMainStore();
return store.validateClientSignature(clientTag, token, signature)
.then(
(response) => response,
() => null
);
}

View file

@ -9,7 +9,7 @@
<script>
// Supporting files
import issPageValues from '@/router/router-constants/issPage-values';
import validateISSClientTag from '@/helpers/clientauth-helper';
import { validateISSClientTag, validateISSClientSignature } from '@/helpers/clientauth-helper';
import { useMainStore } from '@/store';
export default {
@ -60,7 +60,7 @@ export default {
const resp = await validateISSClientTag(clientTag);
if (resp?.data.active && resp?.data.accountName.length > 0) {
this.populateISSConfigValues(resp.data);
await this.populateISSConfigValues(resp.data, clientTag, queryStringParams.token, queryStringParams.signature);
authorized = true;
@ -78,7 +78,7 @@ export default {
window.location = `/?issPage=${issPageValues.WELCOME_PAGE}`;
}
},
populateISSConfigValues(data) {
async populateISSConfigValues(data, clientTag, token, signature) {
this.mainStore.issConfig.clientName = data.accountName;
this.mainStore.issConfig.clientDisplayName = data.accountName; // Defaults to use the client name.
this.mainStore.issConfig.accountNumber = data.accountNumber;
@ -87,7 +87,11 @@ export default {
// NOTE: This is only here for testing purposes.
// Will be removed and replaced by actual token / signature validation when work is completed.
if (data.authentication === 'RSAToken') this.mainStore.issConfig.isAuthenticated = true;
if (data.authentication === 'RSAToken') {
const resp = await validateISSClientSignature(clientTag, token, signature);
console.log(resp.data);
this.mainStore.issConfig.isAuthenticated = resp?.valid ?? false;
}
try {
if (data.clientFlags) {

View file

@ -1518,11 +1518,26 @@ export const useMainStore = defineStore({
async validateClientTag(clientTag) {
return await globalMethods.callHttpClient({
methods: endpoints.ValidateClientTag.method,
method: endpoints.ValidateClientTag.method,
endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`
});
},
async validateClientSignature(clientTag, token, signature) {
const payload = {
clientTag,
token,
signature
};
return await globalMethods.callHttpClient({
method: endpoints.ValidateClientSignature.method,
endpoint: endpoints.ValidateClientSignature.url,
payload
});
},
saveServiceLocation(serviceLocationInfo) {
if (this.order.serviceLocation) {
if (