From a8a2ef5e2767cb35e8c8aec5eeada6fb46146840 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Wed, 15 Feb 2023 11:41:50 +0200 Subject: [PATCH] feat: force auth for particular event types --- models.py | 7 ++-- .../relay-details/relay-details.html | 40 +++++++++++++++++-- .../components/relay-details/relay-details.js | 15 ++++++- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/models.py b/models.py index c00cd15..7e5761e 100644 --- a/models.py +++ b/models.py @@ -66,12 +66,13 @@ class StorageSpec(Spec): class AuthSpec(BaseModel): require_auth_events = Field(False, alias="requireAuthEvents") skiped_auth_events = Field([], alias="skipedAuthEvents") + forced_auth_events = Field([], alias="forcedAuthEvents") require_auth_filter = Field(False, alias="requireAuthFilter") def event_requires_auth(self, kind: int) -> bool: - if not self.require_auth_events: - return False - return kind not in self.skiped_auth_events + if self.require_auth_events: + return kind not in self.skiped_auth_events + return kind in self.forced_auth_events class PaymentSpec(BaseModel): diff --git a/static/components/relay-details/relay-details.html b/static/components/relay-details/relay-details.html index ba235d4..0041c3c 100644 --- a/static/components/relay-details/relay-details.html +++ b/static/components/relay-details/relay-details.html @@ -343,7 +343,7 @@ color="secodary" class="q-ml-md q-mr-md" v-model="relay.config.requireAuthEvents" - >For EventsFor All Events
@@ -388,11 +388,43 @@ > {{ e }} -
+
+
Force Auth For Events:
+
+ +
+
+ +
+
+ + {{ e }} + +
+
Full Storage Action:
diff --git a/static/components/relay-details/relay-details.js b/static/components/relay-details/relay-details.js index 898d7b5..01011db 100644 --- a/static/components/relay-details/relay-details.js +++ b/static/components/relay-details/relay-details.js @@ -18,7 +18,8 @@ async function relayDetails(path) { description: '' } }, - skipEventKind: 0 + skipEventKind: 0, + forceEventKind: 0 } }, @@ -141,6 +142,18 @@ async function relayDetails(path) { value = +eventKind this.relay.config.skipedAuthEvents = this.relay.config.skipedAuthEvents.filter(e => e !== value) + }, + addForceAuthForEvent: function () { + value = +this.forceEventKind + if (this.relay.config.forcedAuthEvents.indexOf(value) != -1) { + return + } + this.relay.config.forcedAuthEvents.push(value) + }, + removeSkipAuthForEvent: function (eventKind) { + value = +eventKind + this.relay.config.forcedAuthEvents = + this.relay.config.forcedAuthEvents.filter(e => e !== value) } },