Fix auth asset embeding & serving
This commit is contained in:
@@ -294,8 +294,8 @@ func (svc service) MountHttpRoutes(r chi.Router) {
|
||||
svc.handlers.MountHttpRoutes(r)
|
||||
|
||||
const uriRoot = "/auth/assets/public"
|
||||
if len(svc.opt.AssetsPath) == 0 {
|
||||
r.Handle(uriRoot+"/*", http.StripPrefix("/auth/assets", http.FileServer(http.FS(publicAssets))))
|
||||
if len(svc.opt.AssetsPath) == 0 && !svc.opt.DevelopmentMode {
|
||||
r.Handle(uriRoot+"/*", http.StripPrefix("/auth/", http.FileServer(http.FS(publicAssets))))
|
||||
} else {
|
||||
var root = strings.TrimRight(svc.opt.AssetsPath, "/") + "/public"
|
||||
r.Handle(uriRoot+"/*", http.StripPrefix(uriRoot, http.FileServer(http.Dir(root))))
|
||||
|
||||
@@ -62,5 +62,5 @@ func (t templateStatic) ExecuteTemplate(w io.Writer, name string, data interface
|
||||
|
||||
// EmbeddedTemplates returns embedded templates.
|
||||
func EmbeddedTemplates(t *template.Template) (tpl *template.Template, err error) {
|
||||
return t.ParseFS(embeddedTemplates, "templates/*.html.tpl")
|
||||
return t.ParseFS(embeddedTemplates, "assets/templates/*.html.tpl")
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func Auth() (o *AuthOpt) {
|
||||
CsrfFieldName: "same-site-authenticity-token",
|
||||
CsrfCookieName: "same-site-authenticity-token",
|
||||
DefaultClient: "corteza-webapp",
|
||||
AssetsPath: "auth/assets",
|
||||
AssetsPath: "",
|
||||
}
|
||||
|
||||
fill(o)
|
||||
|
||||
@@ -135,7 +135,7 @@ props:
|
||||
the need to suply redirection URL and client ID (oauth2/go endpoint does that internally)
|
||||
|
||||
- name: assetsPath
|
||||
default: "auth/assets"
|
||||
default: ""
|
||||
description: |-
|
||||
Path to js, css, images and template source files
|
||||
|
||||
|
||||
Reference in New Issue
Block a user