gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated (58b39bd5 -> 57073eae)


From: gnunet
Subject: [libeufin] branch master updated (58b39bd5 -> 57073eae)
Date: Sun, 24 Sep 2023 21:02:36 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a change to branch master
in repository libeufin.

    from 58b39bd5 native dbinit
     new f3108504 config response
     new 57073eae spa captcha url

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/kotlin/tech/libeufin/bank/BankMessages.kt |  4 ++--
 .../tech/libeufin/bank/IntegrationApiHandlers.kt   | 22 ++++++++--------------
 bank/src/main/kotlin/tech/libeufin/bank/Main.kt    |  5 +++++
 bank/src/main/kotlin/tech/libeufin/bank/helpers.kt | 14 +++-----------
 bank/src/test/kotlin/Common.kt                     |  1 +
 contrib/libeufin-bank.conf                         |  1 +
 6 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
index b12292e3..429a89ef 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
@@ -468,7 +468,7 @@ enum class WithdrawalConfirmationResult {
 @Serializable
 data class TalerIntegrationConfigResponse(
     val name: String = "taler-bank-integration",
-    val version: String = "0:0:0:",
+    val version: String = "0:0:0",
     val currency: String
 )
 
@@ -552,7 +552,7 @@ data class AddIncomingResponse(
 @Serializable
 data class TWGConfigResponse(
     val name: String = "taler-wire-gateway",
-    val version: String = "0:0:0:",
+    val version: String = "0:0:0",
     val currency: String
 )
 
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/IntegrationApiHandlers.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/IntegrationApiHandlers.kt
index 502d8746..51db01f2 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/IntegrationApiHandlers.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/IntegrationApiHandlers.kt
@@ -45,11 +45,11 @@ fun Routing.talerIntegrationHandlers(db: Database, ctx: 
BankApplicationContext)
         val walletCustomer = 
db.customerGetFromRowId(relatedBankAccount.owningCustomerId)
         if (walletCustomer == null)
             throw internalServerError("Could not get the username that owns 
this withdrawal")
-        val confirmUrl = getWithdrawalConfirmUrl(
-            baseUrl = call.request.getBaseUrl() ?: throw 
internalServerError("Could not get bank own base URL."),
-            wopId = wopid,
-            username = walletCustomer.login
-        )
+        val confirmUrl = if (ctx.spaCaptchaURL == null) null else 
+          getWithdrawalConfirmUrl(
+            baseUrl = ctx.spaCaptchaURL,
+            wopId = wopid
+          )
         call.respond(BankWithdrawalOperationStatus(
             aborted = op.aborted,
             selection_done = op.selectionDone,
@@ -94,16 +94,10 @@ fun Routing.talerIntegrationHandlers(db: Database, ctx: 
BankApplicationContext)
             // Whatever the problem, the bank missed it: respond 500.
             throw internalServerError("Bank failed at selecting the 
withdrawal.")
         // Getting user details that MIGHT be used later.
-        val confirmUrl: String? = if (!op.confirmationDone) {
-            val walletBankAccount = 
db.bankAccountGetFromOwnerId(op.walletBankAccount)
-                ?: throw internalServerError("Could not get the bank account 
owning this withdrawal")
-            val walletCustomer = 
db.customerGetFromRowId(walletBankAccount.owningCustomerId)
-                ?: throw internalServerError("Could not get the username 
owning this withdrawal")
+        val confirmUrl: String? = if (ctx.spaCaptchaURL !== null && 
!op.confirmationDone) {
             getWithdrawalConfirmUrl(
-                baseUrl = call.request.getBaseUrl()
-                    ?: throw internalServerError("Could not get bank own base 
URL."),
-                wopId = wopid,
-                username = walletCustomer.login
+                baseUrl = ctx.spaCaptchaURL,
+                wopId = wopid
             )
         }
         else
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
index 025ff5e8..8d4c4a2f 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
@@ -104,6 +104,10 @@ data class BankApplicationContext(
      * Max token duration in microseconds.
      */
     val maxAuthTokenDurationUs: Long,
+    /**
+     * Max token duration in microseconds.
+     */
+    val spaCaptchaURL: String?,
 )
 
 /**
@@ -372,6 +376,7 @@ fun readBankApplicationContextFromConfig(cfg: TalerConfig): 
BankApplicationConte
         suggestedWithdrawalExchange = cfg.lookupValueString("libeufin-bank", 
"suggested_withdrawal_exchange"),
         defaultAdminDebtLimit = cfg.requireValueAmount("libeufin-bank", 
"default_admin_debt_limit", currency),
         maxAuthTokenDurationUs = cfg.requireValueDuration("libeufin-bank", 
"max_auth_token_duration"),
+        spaCaptchaURL = cfg.lookupValueString("libeufin-bank", 
"spa_captcha_url"),
     )
 }
 
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/helpers.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/helpers.kt
index 9969f32c..04d334c3 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/helpers.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/helpers.kt
@@ -335,17 +335,9 @@ fun getTalerWithdrawUri(baseUrl: String, woId: String) = 
url {
 
 // Builds a withdrawal confirm URL.
 fun getWithdrawalConfirmUrl(
-    baseUrl: String, wopId: String, username: String
-) = url {
-    val baseUrlObj = URL(baseUrl)
-    protocol = URLProtocol(name = baseUrlObj.protocol, defaultPort = -1)
-    host = baseUrlObj.host
-    // Removing potential double slashes:
-    baseUrlObj.path.split("/").forEach {
-        this.appendPathSegments(it)
-    }
-    // Completing the endpoint:
-    
this.appendPathSegments("accounts/${username}/withdrawals/${wopId}/confirm")
+    baseUrl: String, wopId: String
+): String {
+    return baseUrl.replace("{woid}", wopId)
 }
 
 
diff --git a/bank/src/test/kotlin/Common.kt b/bank/src/test/kotlin/Common.kt
index 01a36985..ad65c14a 100644
--- a/bank/src/test/kotlin/Common.kt
+++ b/bank/src/test/kotlin/Common.kt
@@ -46,5 +46,6 @@ fun getTestContext(
         registrationBonus = null,
         suggestedWithdrawalExchange = suggestedExchange,
         maxAuthTokenDurationUs = 200 * 1000000,
+        spaCaptchaURL = null,
     )
 }
\ No newline at end of file
diff --git a/contrib/libeufin-bank.conf b/contrib/libeufin-bank.conf
index 04be761f..3d84c20e 100644
--- a/contrib/libeufin-bank.conf
+++ b/contrib/libeufin-bank.conf
@@ -5,6 +5,7 @@ DEFAULT_ADMIN_DEBT_LIMIT = KUDOS:2000
 REGISTRATION_BONUS = KUDOS:100
 REGISTRATION_BONUS_ENABLED = yes
 MAX_AUTH_TOKEN_DURATION = 1d
+SPA_CAPTCHA_URL = http://bank.spa/#/operation/{woip}
 
 SERVE = tcp
 PORT = 8080

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]