Fix to parse the template ahead of time

This commit is contained in:
Ayato 2024-02-27 21:30:41 +09:00
parent ed9ed83bc8
commit a49642c898
No known key found for this signature in database
GPG key ID: 56E05AE09DBA012D

View file

@ -560,17 +560,14 @@ func AuthResponseURL(redirectURI string, responseType oidc.ResponseType, respons
}
//go:embed form_post.html.tmpl
var formPostTemplate string
var formPostHtmlTemplate string
var formPostTmpl = template.Must(template.New("form_post").Parse(formPostHtmlTemplate))
// AuthResponseFormPost responds a html page that automatically submits the form which contains the auth response parameters
func AuthResponseFormPost(w http.ResponseWriter, redirectURI string, response any, encoder httphelper.Encoder) error {
t, err := template.New("form_post").Parse(formPostTemplate)
if err != nil {
return oidc.ErrServerError().WithParent(err)
}
values := make(map[string][]string)
err = encoder.Encode(response, values)
err := encoder.Encode(response, values)
if err != nil {
return oidc.ErrServerError().WithParent(err)
}
@ -583,7 +580,7 @@ func AuthResponseFormPost(w http.ResponseWriter, redirectURI string, response an
Params: values,
}
err = t.Execute(w, params)
err = formPostTmpl.Execute(w, params)
if err != nil {
return oidc.ErrServerError().WithParent(err)
}