diff --git a/frontend/index.html b/frontend/index.html index 350d920..94377de 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -8,84 +8,84 @@ {{ login.Title }} - + -
+ {% verbatim %} +
-
-
+
- +
+ +
@@ -93,12 +93,78 @@ - + + + + {% endverbatim %} diff --git a/main.go b/main.go index 63e6ca0..e7c33fe 100644 --- a/main.go +++ b/main.go @@ -31,11 +31,11 @@ type mainConfig struct { Port int `yaml:"port"` } `yaml:"listen"` Login struct { - Title string `yaml:"title"` - DefaultMethod string `yaml:"default_method"` - DefaultRedirect string `yaml:"default_redirect"` - HideMFAField bool `yaml:"hide_mfa_field"` - Names map[string]string `yaml:"names"` + Title string `yaml:"title" json:"title"` + DefaultMethod string `yaml:"default_method" json:"default_method"` + DefaultRedirect string `yaml:"default_redirect" json:"default_redirect"` + HideMFAField bool `yaml:"hide_mfa_field" json:"hide_mfa_field"` + Names map[string]string `yaml:"names" json:"names"` } `yaml:"login"` Plugins struct { Directory string `yaml:"directory"` diff --git a/plugins/auth.go b/plugins/auth.go index 2f567ec..63f4eaf 100644 --- a/plugins/auth.go +++ b/plugins/auth.go @@ -48,9 +48,9 @@ type Authenticator interface { } type LoginField struct { - Action string - Label string - Name string - Placeholder string - Type string + Action string `json:"action"` + Label string `json:"label"` + Name string `json:"name"` + Placeholder string `json:"placeholder"` + Type string `json:"type"` } diff --git a/pongo.go b/pongo.go new file mode 100644 index 0000000..e7cad98 --- /dev/null +++ b/pongo.go @@ -0,0 +1,28 @@ +package main + +import ( + "bytes" + "encoding/json" + "strings" + + "github.com/flosch/pongo2" +) + +func init() { + pongo2.RegisterFilter("to_json", filterToJSON) +} + +func filterToJSON(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { + var buf = new(bytes.Buffer) + + err := json.NewEncoder(buf).Encode(in.Interface()) + if err != nil { + return nil, &pongo2.Error{ + Sender: "to_json", + OrigError: err, + } + } + + result := strings.TrimSpace(buf.String()) + return pongo2.AsValue(result), nil +}