Skip to content

Commit

Permalink
Fix that custom html headers and static assets got lost when converti…
Browse files Browse the repository at this point in the history
…ng a Caddyfile to JSON with `caddy adapt`
  • Loading branch information
poettig committed Dec 2, 2023
1 parent ede8e8c commit b99262a
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions caddyfile_authn_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/greenpau/caddy-security/pkg/util"
"github.com/greenpau/go-authcrunch/pkg/authn"
"github.com/greenpau/go-authcrunch/pkg/authn/ui"
"io/ioutil"
"strings"
)

Expand Down Expand Up @@ -130,19 +129,7 @@ func parseCaddyfileAuthPortalUI(h *caddyfile.Dispenser, repl *caddy.Replacer, po
case strings.HasPrefix(args, "js"):
portal.UI.CustomJsPath = strings.ReplaceAll(args, "js ", "")
case strings.HasPrefix(args, "html header path"):
args = strings.ReplaceAll(args, "html header path ", "")
b, err := ioutil.ReadFile(args)
if err != nil {
return h.Errf("%s %s subdirective: %s %v", rootDirective, subDirective, args, err)
}
for k, v := range ui.PageTemplates {
headIndex := strings.Index(v, "<meta name=\"description\"")
if headIndex < 1 {
continue
}
v = v[:headIndex] + string(b) + v[headIndex:]
ui.PageTemplates[k] = v
}
portal.UI.CustomHTMLHeaderPath = strings.ReplaceAll(args, "html header path ", "")

Check failure on line 132 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

portal.UI.CustomHTMLHeaderPath undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method CustomHTMLHeaderPath)

Check failure on line 132 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

portal.UI.CustomHTMLHeaderPath undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method CustomHTMLHeaderPath)

Check failure on line 132 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

portal.UI.CustomHTMLHeaderPath undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method CustomHTMLHeaderPath)

Check failure on line 132 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

portal.UI.CustomHTMLHeaderPath undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method CustomHTMLHeaderPath)
case args == "":
return h.Errf("%s %s directive has no value", rootDirective, subDirective)
default:
Expand All @@ -161,9 +148,11 @@ func parseCaddyfileAuthPortalUI(h *caddyfile.Dispenser, repl *caddy.Replacer, po
return h.Errf("auth backend %s subdirective %s URI must be prefixed with %s, got %s",
rootDirective, subDirective, prefix, assetURI)
}
if err := ui.StaticAssets.AddAsset(assetURI, assetContentType, assetPath); err != nil {
return h.Errf("auth backend %s subdirective %s failed: %s", rootDirective, subDirective, err)
}
portal.UI.StaticAssets = append(portal.UI.StaticAssets, ui.StaticAsset{

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)

Check failure on line 151 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

portal.UI.StaticAssets undefined (type *"github.com/greenpau/go-authcrunch/pkg/authn/ui".Parameters has no field or method StaticAssets)
Path: assetURI,
FsPath: assetPath,

Check failure on line 153 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

unknown field FsPath in struct literal of type "github.com/greenpau/go-authcrunch/pkg/authn/ui".StaticAsset

Check failure on line 153 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x, ubuntu-latest)

unknown field FsPath in struct literal of type "github.com/greenpau/go-authcrunch/pkg/authn/ui".StaticAsset

Check failure on line 153 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

unknown field FsPath in struct literal of type "github.com/greenpau/go-authcrunch/pkg/authn/ui".StaticAsset

Check failure on line 153 in caddyfile_authn_ui.go

View workflow job for this annotation

GitHub Actions / Build (1.21.x, ubuntu-latest)

unknown field FsPath in struct literal of type "github.com/greenpau/go-authcrunch/pkg/authn/ui".StaticAsset
ContentType: assetContentType,
})
case "disable":
args := util.FindReplaceAll(repl, h.RemainingArgs())
if err := portal.UI.DisablePage(args); err != nil {
Expand Down

0 comments on commit b99262a

Please sign in to comment.