added consent template

This commit is contained in:
ston1th 2022-07-10 01:19:28 +02:00
commit 3c3ca3e7a7
6 changed files with 31 additions and 6 deletions

View file

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

View file

@ -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,
)

View file

@ -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":

View file

@ -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")

View file

@ -0,0 +1,24 @@
{{define "body"}}
{{if .Data}}
<div class="row">
<div class="col-xs-4 offset-4">
<div class="card border-primary mx-auto">
<div class="card-header">
<strong>{{.BodyTitle}}</strong>
</div>
<div class="card-body">
<pre>
{{.Data.Info}}
</pre>
<form class="form-horizontal" action="/consent" method="post">
<input type="hidden" name="token" value="{{.Token}}">
<input type="hidden" name="consent_challenge" value="{{.Data.ConsentChallenge}}">
<button class="btn btn-sm btn-primary" type="submit" name="Approve">Approve</button>
<button class="btn btn-sm btn-primary" type="submit" name="Reject">Reject</button>
</form>
</div>
</div>
</div>
</div>
{{end}}
{{end}}

2
sri.sh
View file

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (C) 2021 Marius Schellenberger
# Copyright (C) 2022 Marius Schellenberger
HASH="sha256"
DIR="pkg/server/static"