@@ -20,7 +20,6 @@ import (
20
20
"github.com/greenpau/caddy-security/pkg/util"
21
21
"github.com/greenpau/go-authcrunch/pkg/authn"
22
22
"github.com/greenpau/go-authcrunch/pkg/authn/ui"
23
- "io/ioutil"
24
23
"strings"
25
24
)
26
25
@@ -130,19 +129,7 @@ func parseCaddyfileAuthPortalUI(h *caddyfile.Dispenser, repl *caddy.Replacer, po
130
129
case strings .HasPrefix (args , "js" ):
131
130
portal .UI .CustomJsPath = strings .ReplaceAll (args , "js " , "" )
132
131
case strings .HasPrefix (args , "html header path" ):
133
- args = strings .ReplaceAll (args , "html header path " , "" )
134
- b , err := ioutil .ReadFile (args )
135
- if err != nil {
136
- return h .Errf ("%s %s subdirective: %s %v" , rootDirective , subDirective , args , err )
137
- }
138
- for k , v := range ui .PageTemplates {
139
- headIndex := strings .Index (v , "<meta name=\" description\" " )
140
- if headIndex < 1 {
141
- continue
142
- }
143
- v = v [:headIndex ] + string (b ) + v [headIndex :]
144
- ui .PageTemplates [k ] = v
145
- }
132
+ portal .UI .CustomHTMLHeaderPath = strings .ReplaceAll (args , "html header path " , "" )
146
133
case args == "" :
147
134
return h .Errf ("%s %s directive has no value" , rootDirective , subDirective )
148
135
default :
@@ -161,9 +148,11 @@ func parseCaddyfileAuthPortalUI(h *caddyfile.Dispenser, repl *caddy.Replacer, po
161
148
return h .Errf ("auth backend %s subdirective %s URI must be prefixed with %s, got %s" ,
162
149
rootDirective , subDirective , prefix , assetURI )
163
150
}
164
- if err := ui .StaticAssets .AddAsset (assetURI , assetContentType , assetPath ); err != nil {
165
- return h .Errf ("auth backend %s subdirective %s failed: %s" , rootDirective , subDirective , err )
166
- }
151
+ portal .UI .StaticAssets = append (portal .UI .StaticAssets , ui.StaticAsset {
152
+ Path : assetURI ,
153
+ FsPath : assetPath ,
154
+ ContentType : assetContentType ,
155
+ })
167
156
case "disable" :
168
157
args := util .FindReplaceAll (repl , h .RemainingArgs ())
169
158
if err := portal .UI .DisablePage (args ); err != nil {
0 commit comments