From 2ff7fcd5eaff72ffd50500b4fa799922e66b53d6 Mon Sep 17 00:00:00 2001 From: Peter Oettig Date: Sun, 3 Dec 2023 01:37:07 +0100 Subject: [PATCH] Move loading of custom HTML headers and static assets (#49) * Move loading of custom HTML headers and static assets from caddy-security to here * Sign CLA --- assets/cla/consent.yaml | 2 ++ pkg/authn/portal.go | 22 ++++++++++++++++++++++ pkg/authn/ui/params.go | 2 ++ pkg/authn/ui/static.go | 5 +++-- pkg/errors/auth.go | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/assets/cla/consent.yaml b/assets/cla/consent.yaml index ce8bcb6..cf3edf6 100644 --- a/assets/cla/consent.yaml +++ b/assets/cla/consent.yaml @@ -41,4 +41,6 @@ email: ng-cla@openenterprise.co.uk - name: Michael Ellis email: Michael94Ellis@gmail.com +- name: Peter Oettig + email: oss-cla@oettig.de diff --git a/pkg/authn/portal.go b/pkg/authn/portal.go index 233d752..7291c16 100644 --- a/pkg/authn/portal.go +++ b/pkg/authn/portal.go @@ -16,6 +16,7 @@ package authn import ( "context" + "os" "sort" "github.com/greenpau/go-authcrunch/pkg/acl" @@ -488,6 +489,27 @@ func (p *Portal) configureUserInterface() error { } } + if p.config.UI.CustomHTMLHeaderPath != "" { + b, err := os.ReadFile(p.config.UI.CustomHTMLHeaderPath) + if err != nil { + return errors.ErrCustomHTMLHeaderNotReadable.WithArgs(p.config.UI.CustomHTMLHeaderPath, p.config.Name, err) + } + for k, v := range ui.PageTemplates { + headIndex := strings.Index(v, "