gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Fixing token handler.


From: gnunet
Subject: [libeufin] branch master updated: Fixing token handler.
Date: Mon, 25 Sep 2023 16:41:58 +0200

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

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new b56753b1 Fixing token handler.
b56753b1 is described below

commit b56753b146c79b11a9f879b53b5f4403708b1c10
Author: MS <ms@taler.net>
AuthorDate: Mon Sep 25 16:39:53 2023 +0200

    Fixing token handler.
    
    Fixed items:
    
    - token creation time in the database.
    - testcase still mentioning the wrong token prefix.
---
 bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt        | 2 +-
 bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt | 9 +++++----
 bank/src/test/kotlin/LibeuFinApiTest.kt                        | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
index 86d52ccd..0ca325f7 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
@@ -392,7 +392,7 @@ data class BankAccountTransactionInfo(
     val direction: TransactionDirection,
     val subject: String,
     val row_id: Long, // is T_ID
-    val date: Long
+    val date: TalerProtocolTimestamp
 )
 
 // Response type for histories, namely GET /transactions
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt
index 75316979..378b1c1b 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt
@@ -59,7 +59,8 @@ fun Routing.accountsMgmtHandlers(db: Database, ctx: 
BankApplicationContext) {
         val customerDbRow = customer.dbRowId ?: throw internalServerError(
             "Could not get customer '${customer.login}' database row ID"
         )
-        val expirationTimestampUs: Long = getNowUs() + tokenDurationUs
+        val creationTime = getNowUs()
+        val expirationTimestampUs: Long = creationTime + tokenDurationUs
         if (expirationTimestampUs < tokenDurationUs) throw badRequest(
             "Token duration caused arithmetic overflow", // FIXME: need 
dedicate EC (?)
             talerErrorCode = TalerErrorCode.TALER_EC_END
@@ -67,7 +68,7 @@ fun Routing.accountsMgmtHandlers(db: Database, ctx: 
BankApplicationContext) {
         val token = BearerToken(
             bankCustomer = customerDbRow,
             content = tokenBytes,
-            creationTime = expirationTimestampUs,
+            creationTime = creationTime,
             expirationTime = expirationTimestampUs,
             scope = req.scope,
             isRefreshable = req.refreshable
@@ -349,7 +350,7 @@ fun Routing.accountsMgmtHandlers(db: Database, ctx: 
BankApplicationContext) {
                     subject = it.subject,
                     amount = it.amount.toString(),
                     direction = it.direction,
-                    date = it.transactionDate,
+                    date = 
TalerProtocolTimestamp.fromMicroseconds(it.transactionDate),
                     row_id = it.dbRowId ?: throw internalServerError(
                         "Transaction timestamped with '${it.transactionDate}' 
did not have row ID"
                     )
@@ -424,7 +425,7 @@ fun Routing.accountsMgmtHandlers(db: Database, ctx: 
BankApplicationContext) {
                 amount = 
"${tx.amount.currency}:${tx.amount.value}.${tx.amount.frac}",
                 creditor_payto_uri = tx.creditorPaytoUri,
                 debtor_payto_uri = tx.debtorPaytoUri,
-                date = tx.transactionDate,
+                date = 
TalerProtocolTimestamp.fromMicroseconds(tx.transactionDate),
                 direction = tx.direction,
                 subject = tx.subject,
                 row_id = txRowId
diff --git a/bank/src/test/kotlin/LibeuFinApiTest.kt 
b/bank/src/test/kotlin/LibeuFinApiTest.kt
index 2c14d45f..c0cbaaa5 100644
--- a/bank/src/test/kotlin/LibeuFinApiTest.kt
+++ b/bank/src/test/kotlin/LibeuFinApiTest.kt
@@ -173,7 +173,7 @@ class LibeuFinApiTest {
             )
             // Testing the bearer-token:-scheme.
             client.post("/accounts/foo/token") {
-                headers.set("Authorization", "Bearer 
bearer-token:${Base32Crockford.encode(fooTok)}")
+                headers.set("Authorization", "Bearer 
secret-token:${Base32Crockford.encode(fooTok)}")
                 contentType(ContentType.Application.Json)
                 setBody("{\"scope\": \"readonly\"}")
                 expectSuccess = true

-- 
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]