From 3c3ca3e7a7915b910326c88298609970effcabe5 Mon Sep 17 00:00:00 2001 From: ston1th Date: Sun, 10 Jul 2022 01:19:28 +0200 Subject: [PATCH] added consent template --- COPYRIGHT | 2 +- pkg/server/context.go | 6 +++--- pkg/server/handler.go | 2 +- pkg/server/templates.go | 1 + pkg/server/templates/consent.html | 24 ++++++++++++++++++++++++ sri.sh | 2 +- 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 pkg/server/templates/consent.html diff --git a/COPYRIGHT b/COPYRIGHT index ef3977c..84bca3c 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,4 +1,4 @@ -Copyright (C) 2021 Marius Schellenberger +Copyright (C) 2022 Marius Schellenberger This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/pkg/server/context.go b/pkg/server/context.go index c933b1c..485eae3 100644 --- a/pkg/server/context.go +++ b/pkg/server/context.go @@ -87,7 +87,7 @@ type loginData struct { type consentData struct { ConsentChallenge string - Data *consentInfo + Info *consentInfo } func (c *Context) Exec() { @@ -132,7 +132,7 @@ func (c *Context) Exec() { func (c *Context) accessLog() { log := c.log.WithValues("addr", c.Request.RemoteAddr, "method", c.Request.Method, - "url", c.Request.RequestURI, + "uri", c.Request.RequestURI, "status", c.Status, ) if c.Err != nil { @@ -184,7 +184,7 @@ func (c *Context) SetHeader(name, value string) { func (c *Context) Redirect(uri string, code int) { c.log.Info("access", "addr", c.Request.RemoteAddr, "method", c.Request.Method, - "url", c.Request.RequestURI, + "uri", c.Request.RequestURI, "status", code, "redirect", uri, ) diff --git a/pkg/server/handler.go b/pkg/server/handler.go index 3150725..42a5a29 100644 --- a/pkg/server/handler.go +++ b/pkg/server/handler.go @@ -250,7 +250,7 @@ func consentHandler(ctx *Context) { ctx.Error(err) return } - data.Data = ci + data.Info = ci ctx.Data.Data = data ctx.Exec() case "POST": diff --git a/pkg/server/templates.go b/pkg/server/templates.go index d21d817..83dcf98 100644 --- a/pkg/server/templates.go +++ b/pkg/server/templates.go @@ -45,6 +45,7 @@ func (s *Server) loadTemplates() (err error) { s.ts.Parse(tfs, "notFoundHandler", "index.html", "menu.html", "notFound.html") s.ts.Parse(tfs, "loginHandler", "index.html", "menu.html", "login.html") s.ts.Parse(tfs, "loginTotpHandler", "index.html", "menu.html", "loginTotp.html") + s.ts.Parse(tfs, "consentHandler", "index.html", "menu.html", "consent.html") // users s.ts.Parse(tfs, "usersHandler", "index.html", "menu.html", "users.html") s.ts.Parse(tfs, "userNewHandler", "index.html", "menu.html", "userNew.html") diff --git a/pkg/server/templates/consent.html b/pkg/server/templates/consent.html new file mode 100644 index 0000000..4663a64 --- /dev/null +++ b/pkg/server/templates/consent.html @@ -0,0 +1,24 @@ +{{define "body"}} +{{if .Data}} +
+
+
+
+ {{.BodyTitle}} +
+
+
+{{.Data.Info}}
+
+
+ + + + +
+
+
+
+
+{{end}} +{{end}} diff --git a/sri.sh b/sri.sh index 9f6e924..f37aa62 100755 --- a/sri.sh +++ b/sri.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2021 Marius Schellenberger +# Copyright (C) 2022 Marius Schellenberger HASH="sha256" DIR="pkg/server/static"