[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 03/07: Jinja and form-auth experiments
From: |
gnunet |
Subject: |
[libeufin] 03/07: Jinja and form-auth experiments |
Date: |
Tue, 29 Jun 2021 15:59:14 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit 1117d23adcbb41661968859e0efe52d34e05ac33
Author: ms <ms@taler.net>
AuthorDate: Tue Jun 29 11:39:02 2021 +0200
Jinja and form-auth experiments
---
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 44 +++++++++++++++++++---
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 3d96517..db04d57 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -227,8 +227,16 @@ fun serverMain(dbName: String, port: Int) {
}
install(Authentication) {
// Web-based authentication for Bank customers.
- form {
-
+ form("auth-form") {
+ userParamName = "username"
+ passwordParamName = "password"
+ validate { credentials ->
+ if (credentials.name == "test") {
+ UserIdPrincipal(credentials.name)
+ } else {
+ null
+ }
+ }
}
}
install(ContentNegotiation) {
@@ -302,6 +310,24 @@ fun serverMain(dbName: String, port: Int) {
}
}
routing {
+ /*
+
+ FIXME: commenting out until a solution for i18n is found.
+
+ get("/bank") {
+ val ret = renderTemplate(
+ "login.html",
+ mapOf("csrf_token" to "todo", )
+ )
+ call.respondText(ret)
+ return@get
+ } */
+
+ post("/register") {
+ // how to read form-POSTed values?
+
+ }
+
get("/jinja-test") {
val template = Resources.toString(
Resources.getResource("templates/hello.html"),
@@ -313,6 +339,15 @@ fun serverMain(dbName: String, port: Int) {
return@get
}
+ authenticate("auth-form") {
+ get("/profile") {
+ val userSession = call.principal<UserIdPrincipal>()
+ println("Welcoming ${userSession?.name}")
+ call.respond(object {})
+ return@get
+ }
+ }
+
static("/static") {
/**
* Here Sandbox will serve the CSS files.
@@ -400,13 +435,12 @@ fun serverMain(dbName: String, port: Int) {
post("/admin/ebics/bank-accounts") {
val body = call.receiveJson<BankAccountRequest>()
transaction {
- val subscriber = getEbicsSubscriberFromDetails(
+ var subscriber = getEbicsSubscriberFromDetails(
body.subscriber.userID,
body.subscriber.partnerID,
body.subscriber.hostID
)
- BankAccountEntity.new {
- this.subscriber = subscriber
+ subscriber.bankAccount = BankAccountEntity.new {
iban = body.iban
bic = body.bic
name = body.name
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (62d0490 -> 786b70a), gnunet, 2021/06/29
- [libeufin] 05/07: drafting bank config table, gnunet, 2021/06/29
- [libeufin] 07/07: helper that returns a bank configuration, given the hostname., gnunet, 2021/06/29
- [libeufin] 06/07: CLI command to configure the Sandbox, gnunet, 2021/06/29
- [libeufin] 01/07: DB: making Ebics subscriber point at bank accounts., gnunet, 2021/06/29
- [libeufin] 02/07: Commenting out Jinja initialization., gnunet, 2021/06/29
- [libeufin] 03/07: Jinja and form-auth experiments,
gnunet <=
- [libeufin] 04/07: drafting user creation, gnunet, 2021/06/29