mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 10:26:29 +02:00
49 lines
964 B
Go
49 lines
964 B
Go
package controlplane
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
)
|
|
|
|
//go:embed luascripts
|
|
var luaFS embed.FS
|
|
|
|
var luascripts struct {
|
|
ExtAuthzSetCookie string
|
|
CleanUpstream string
|
|
RemoveImpersonateHeaders string
|
|
FixMisdirected string
|
|
}
|
|
|
|
func init() {
|
|
fileToField := map[string]*string{
|
|
"luascripts/clean-upstream.lua": &luascripts.CleanUpstream,
|
|
"luascripts/ext-authz-set-cookie.lua": &luascripts.ExtAuthzSetCookie,
|
|
"luascripts/remove-impersonate-headers.lua": &luascripts.RemoveImpersonateHeaders,
|
|
"luascripts/fix-misdirected.lua": &luascripts.FixMisdirected,
|
|
}
|
|
|
|
err := fs.WalkDir(luaFS, "luascripts", func(p string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if d.IsDir() {
|
|
return nil
|
|
}
|
|
|
|
bs, err := luaFS.ReadFile(p)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if ptr, ok := fileToField[p]; ok {
|
|
*ptr = string(bs)
|
|
}
|
|
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|