From 39c7b032f00579e4b2f11ae83617e3331cb52304 Mon Sep 17 00:00:00 2001 From: F-Node-Karlsruhe Date: Thu, 29 Jun 2023 13:09:44 +0200 Subject: [PATCH] improve auth flow Signed-off-by: F-Node-Karlsruhe --- CHANGELOG.md | 7 ++++++ api/package.json | 2 +- frontend/package.json | 2 +- frontend/src/components/AuthModal.vue | 28 +++++++++++++++-------- frontend/src/components/DiscloseModal.vue | 16 ++++++++++--- frontend/src/store/index.js | 6 ++--- frontend/src/utils.js | 5 ++++ frontend/src/views/Verify.vue | 11 ++++++--- 8 files changed, 56 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4df31a9..319a81c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ WIP --- +1.6.4 (2023-06-29) +--- + +- use authentication for inital fetchif present +- general improvements to authentication + + 1.6.3 (2023-06-27) --- diff --git a/api/package.json b/api/package.json index a224211..22b9420 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "vc-verifier", - "version": "1.6.3", + "version": "1.6.4", "description": "The EECC verifier for verifiable credentials which provides an verification API as well as the corresponding UI.", "main": "index.js", "type": "module", diff --git a/frontend/package.json b/frontend/package.json index 3841888..d8c560c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "verifier_frontend", - "version": "1.6.3", + "version": "1.6.4", "description": "Vue frontend for the EECC vc verifier API", "scripts": { "build": "vue-cli-service build", diff --git a/frontend/src/components/AuthModal.vue b/frontend/src/components/AuthModal.vue index c224926..601904c 100644 --- a/frontend/src/components/AuthModal.vue +++ b/frontend/src/components/AuthModal.vue @@ -14,7 +14,7 @@
+ id="useDemoSwitch" :checked="isDemoAuth">
@@ -43,18 +43,21 @@
Authenticate with your wallet
- +
@@ -65,7 +68,7 @@ \ No newline at end of file diff --git a/frontend/src/components/DiscloseModal.vue b/frontend/src/components/DiscloseModal.vue index cf24226..da3093f 100644 --- a/frontend/src/components/DiscloseModal.vue +++ b/frontend/src/components/DiscloseModal.vue @@ -14,7 +14,7 @@
+ id="useDemoSwitch" :checked="isDemoAuth">
@@ -45,7 +45,7 @@
authenticate with your wallet
- +
@@ -63,6 +63,7 @@ import PresentationRequest from './PresentationRequest.vue'; import { demoAuthPresentation } from '@/store/demoAuth'; import { Modal } from 'bootstrap'; +import { isDemoAuth } from "../utils.js"; export default { name: 'DiscloseModal', @@ -76,10 +77,19 @@ export default { }, data() { return { - demoAuth: demoAuthPresentation + demoAuth: demoAuthPresentation, + active: false } }, + mounted() { + const modal = document.getElementById(this.id) + modal.addEventListener('show.bs.modal', () => this.active = true) + modal.addEventListener('hide.bs.modal', () => this.active = false) + }, computed: { + isDemoAuth() { + return isDemoAuth(this.authentication); + }, authentication: { get() { return this.$store.state.authentication; diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 4ab3481..397eb5c 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -1,12 +1,12 @@ import { createStore } from 'vuex' import api from '../api' -import { demoAuthPresentation } from './demoAuth'; + export default createStore({ state: { - version: '1.6.3', - authentication: demoAuthPresentation, + version: '1.6.4', + authentication: undefined, verifiables: [], disclosedCredentials: [], VC_REGISTRY: process.env.VC_REGISTRY || 'https://ssi.eecc.de/api/registry/vcs/', diff --git a/frontend/src/utils.js b/frontend/src/utils.js index 0c8be1d..c3b2bf3 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -1,4 +1,5 @@ import jsonld from 'jsonld'; +import { demoAuthPresentation } from './store/demoAuth'; export const VerifiableType = { CREDENTIAL: 'VerifiableCredential', @@ -83,3 +84,7 @@ export async function getContext(credential) { return resolved.mappings; } +export function isDemoAuth(auth) { + return auth != undefined && JSON.stringify(auth) == JSON.stringify(demoAuthPresentation); +} + diff --git a/frontend/src/views/Verify.vue b/frontend/src/views/Verify.vue index 4854dca..3510342 100644 --- a/frontend/src/views/Verify.vue +++ b/frontend/src/views/Verify.vue @@ -75,6 +75,9 @@ export default { }); }, computed: { + authenctication() { + return this.$store.state.authentication; + }, storeVerifiables() { return this.$store.state.verifiables; }, @@ -135,16 +138,18 @@ export default { this.$store.dispatch("resetVerifiables"); verifiables.map(async v => await this.verify(v)); }, + async fetchAuth(url) { + return this.authenctication ? await this.$api.post(url, { vp: this.authenctication }) : await this.$api.get(url); + }, async fetchData() { - if (this.credentialId) { - const res = await this.$api.get(this.credentialId); + const res = await this.fetchAuth(this.credentialId); this.verifiables.push(res.data); return } if (this.subjectId) { - const res = await this.$api.get(this.$store.state.VC_REGISTRY + encodeURIComponent(this.subjectId)); + const res = await this.fetchAuth(this.$store.state.VC_REGISTRY + encodeURIComponent(this.subjectId)); this.verifiables = res.data return }