1
0
mirror of https://github.com/greenpau/caddy-security.git synced 2025-04-18 08:04:02 +03:00

feature: add caddy directive replacer to user transforms

This commit is contained in:
Paul Greenberg 2024-04-09 08:32:16 -04:00
parent 4992f12a8c
commit 2ce3bc5097

View File

@ -17,6 +17,7 @@ package security
import (
"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
"github.com/greenpau/caddy-security/pkg/util"
"github.com/greenpau/go-authcrunch/pkg/authn"
"github.com/greenpau/go-authcrunch/pkg/authn/transformer"
cfgutil "github.com/greenpau/go-authcrunch/pkg/util/cfg"
@ -29,8 +30,8 @@ func parseCaddyfileAuthPortalTransform(h *caddyfile.Dispenser, repl *caddy.Repla
case "user", "users":
tc := &transformer.Config{}
for nesting := h.Nesting(); h.NextBlock(nesting); {
trKey := h.Val()
trArgs := h.RemainingArgs()
trKey := util.FindReplace(repl, h.Val())
trArgs := util.FindReplaceAll(repl, h.RemainingArgs())
trArgs = append([]string{trKey}, trArgs...)
encodedArgs := cfgutil.EncodeArgs(trArgs)
var matchArgs bool