diff --git a/server/ctrl/session.go b/server/ctrl/session.go index 7ef85f19..89e6e47b 100644 --- a/server/ctrl/session.go +++ b/server/ctrl/session.go @@ -1,6 +1,7 @@ package ctrl import ( + "bytes" "encoding/json" "github.com/gorilla/mux" . "github.com/mickael-kerjean/filestash/server/common" @@ -9,6 +10,7 @@ import ( "net/http" "net/url" "strings" + "text/template" "time" ) @@ -312,7 +314,20 @@ func SessionAuthMiddleware(ctx App, res http.ResponseWriter, req *http.Request) } mappingToUse := map[string]string{} for k, v := range globalMapping[refCookie.Value] { - mappingToUse[k] = NewStringFromInterface(v) + str := NewStringFromInterface(v) + if str == "" { + continue + } + tmpl, err := template.New("ctrl::session::auth_middleware").Parse(str) + mappingToUse[k] = str + if err != nil { + continue + } + var b bytes.Buffer + if err = tmpl.Execute(&b, tb); err != nil { + continue + } + mappingToUse[k] = b.String() } mappingToUse["timestamp"] = time.Now().String() return mappingToUse, nil diff --git a/server/plugin/plg_authenticate_admin/index.go b/server/plugin/plg_authenticate_admin/index.go index 5c91becb..bb5de298 100644 --- a/server/plugin/plg_authenticate_admin/index.go +++ b/server/plugin/plg_authenticate_admin/index.go @@ -68,5 +68,7 @@ func (this Admin) Callback(formData map[string]string, idpParams map[string]stri }) return nil, ErrAuthenticationFailed } - return map[string]string{}, nil + return map[string]string{ + "username": "admin", + }, nil }