gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: renaming


From: gnunet
Subject: [libeufin] branch master updated: renaming
Date: Thu, 14 Oct 2021 15:51:55 +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 5888c52  renaming
5888c52 is described below

commit 5888c5283bce2400d655cc9e29823f99a144b504
Author: ms <ms@taler.net>
AuthorDate: Thu Oct 14 15:51:52 2021 +0200

    renaming
---
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 3 +++
 util/src/main/kotlin/Config.kt                        | 8 +++++++-
 util/src/main/kotlin/HTTP.kt                          | 5 +++--
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index d3ec449..97789b0 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -463,6 +463,9 @@ val sandboxApp: Application.() -> Unit = {
         call.application.apply {
             if (adminPassword != null) {
                 call.attributes.put(AttributeKey("adminPassword"), 
adminPassword)
+                /**
+                 * When not given, the checker expects --no-auth to have been 
specified on the CLI.
+                 */
             }
         }
     }
diff --git a/util/src/main/kotlin/Config.kt b/util/src/main/kotlin/Config.kt
index de47466..ac4497d 100644
--- a/util/src/main/kotlin/Config.kt
+++ b/util/src/main/kotlin/Config.kt
@@ -52,7 +52,13 @@ fun setLogLevel(logLevel: String?) {
     }
 }
 
-internal fun <T : Any>ApplicationCall.getAttribute(name: String): T {
+internal fun <T : Any>ApplicationCall.maybeAttribute(name: String): T? {
+    val key = AttributeKey<T>("name")
+    if (!this.attributes.contains(key)) return null
+    return this.attributes[key]
+}
+
+internal fun <T : Any>ApplicationCall.ensureAttribute(name: String): T {
     val key = AttributeKey<T>("name")
     if (!this.attributes.contains(key))
         throw internalServerError("Attribute $name not found along the call.")
diff --git a/util/src/main/kotlin/HTTP.kt b/util/src/main/kotlin/HTTP.kt
index a91c380..b902a8e 100644
--- a/util/src/main/kotlin/HTTP.kt
+++ b/util/src/main/kotlin/HTTP.kt
@@ -89,14 +89,15 @@ fun ApplicationRequest.getBaseUrl(): String {
  * environment.
  */
 fun ApplicationRequest.basicAuth() {
-    val withAuth = this.call.getAttribute<Boolean>("withAuth")
+    val withAuth = this.call.ensureAttribute<Boolean>("withAuth")
     if (!withAuth) {
         logger.info("Authentication is disabled - assuming tests currently 
running.")
         return
     }
     val credentials = getHTTPBasicAuthCredentials(this)
     if (credentials.first == "admin") {
-        val adminPassword = this.call.getAttribute<String>("adminPassword")
+        // env must contain the admin password, because --with-auth is true.
+        val adminPassword = this.call.ensureAttribute<String>("adminPassword")
         if (credentials.second != adminPassword) throw unauthorized(
             "Admin authentication failed"
         )

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