From 0e41e6518c80f25d7b85414bdba947a88910821a Mon Sep 17 00:00:00 2001
From: clauspeterhuebner
Date: Wed, 16 Apr 2025 01:39:24 +0200
Subject: [PATCH] remove check against referrer and in case of invalid signing
use simply decoded payload
---
.../resolver/TransactionLinkResolver.ts | 23 +++++++++++--------
.../RedeemCommunitySelection.vue | 2 --
.../RedeemSelectCommunity.vue | 2 --
frontend/src/graphql/queries.js | 4 ++--
frontend/src/pages/TransactionLink.vue | 16 ++-----------
frontend/src/routes/routes.js | 15 ------------
6 files changed, 17 insertions(+), 45 deletions(-)
diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts
index 7b255be45..6f142d01a 100644
--- a/backend/src/graphql/resolver/TransactionLinkResolver.ts
+++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts
@@ -143,10 +143,7 @@ export class TransactionLinkResolver {
@Authorized([RIGHTS.QUERY_TRANSACTION_LINK])
@Query(() => QueryLinkResult)
- async queryTransactionLink(
- @Arg('code') code: string,
- @Arg('referrer') referrer: string,
- ): Promise {
+ async queryTransactionLink(@Arg('code') code: string): Promise {
logger.debug('TransactionLinkResolver.queryTransactionLink... code=', code)
const transactionLink = new TransactionLink()
if (code.match(/^CL-/)) {
@@ -210,18 +207,24 @@ export class TransactionLinkResolver {
disburseJwtPayload.sendercommunityuuid,
)
}
- const senderUrl = senderCom.url.replace(/\/api\/?$/, '')
- if (!senderUrl.startsWith(referrer)) {
- throw new LogError('Sender community does not match referrer', senderCom.name, referrer)
- }
if (!senderCom.communityUuid) {
throw new LogError('Sender community UUID is not set')
}
// now with the sender community UUID the jwt token can be verified
- const jwtPayload = await verify(code, senderCom.communityUuid)
+ let jwtPayload = await verify(code, senderCom.communityUuid)
+ // TODO: as long as the verification fails, fallback to decode
+ if (jwtPayload === null) {
+ jwtPayload = decode(code)
+ }
logger.debug('TransactionLinkResolver.queryTransactionLink... jwtPayload=', jwtPayload)
if (jwtPayload !== null && jwtPayload instanceof DisbursementJwtPayloadType) {
- const disburseJwtPayload: DisbursementJwtPayloadType = jwtPayload
+ const disburseJwtPayload = new DisbursementJwtPayloadType(jwtPayload.sendercommunityuuid,
+ jwtPayload.sendergradidoid,
+ jwtPayload.sendername,
+ jwtPayload.redeemcode,
+ jwtPayload.amount,
+ jwtPayload.memo,
+ )
logger.debug(
'TransactionLinkResolver.queryTransactionLink... disburseJwtPayload=',
disburseJwtPayload,
diff --git a/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue b/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue
index dcc83b3cd..5ae6b69fe 100644
--- a/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue
+++ b/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue
@@ -2,7 +2,6 @@