diff --git a/server/config.go b/server/config.go index 35e19a96..87372468 100644 --- a/server/config.go +++ b/server/config.go @@ -8,6 +8,7 @@ import ( "io" "net/url" "os" + "path" "path/filepath" texttemplate "text/template" "time" @@ -63,7 +64,7 @@ func (cfg *ServerConfig) Server() (*Server, error) { return nil, err } - tpl, err := getTemplates(cfg.IssuerName, cfg.IssuerLogoURL, cfg.EnableRegistration, cfg.TemplateDir) + tpl, err := getTemplates(cfg.IssuerName, cfg.IssuerURL, cfg.IssuerLogoURL, cfg.EnableRegistration, cfg.TemplateDir) if err != nil { return nil, err } @@ -281,8 +282,14 @@ func (cfg *MultiServerConfig) Configure(srv *Server) error { return nil } -func getTemplates(issuerName, issuerLogoURL string, +func getTemplates(issuerName, issuerURL, issuerLogoURL string, enableRegister bool, dir string) (*template.Template, error) { + u, err := url.Parse(issuerURL) + if err != nil { + return nil, err + } + issuerPath := u.Path + tpl := template.New("").Funcs(map[string]interface{}{ "issuerName": func() string { return issuerName @@ -293,6 +300,9 @@ func getTemplates(issuerName, issuerLogoURL string, "enableRegister": func() bool { return enableRegister }, + "absPath": func(p string) string { + return path.Join(issuerPath, p) + }, }) return tpl.ParseGlob(dir + "/*.html") diff --git a/server/testutil_test.go b/server/testutil_test.go index 0ef7bfa0..e7c07060 100644 --- a/server/testutil_test.go +++ b/server/testutil_test.go @@ -230,7 +230,7 @@ func makeTestFixturesWithOptions(options testFixtureOptions) (*testFixtures, err return nil, err } - tpl, err := getTemplates("dex", + tpl, err := getTemplates("dex", "https://coreos.com", "https://coreos.com/assets/images/brand/coreos-mark-30px.png", true, templatesLocation) if err != nil { diff --git a/static/html/ldap-login.html b/static/html/ldap-login.html index 4ea4cd65..3a80c5af 100644 --- a/static/html/ldap-login.html +++ b/static/html/ldap-login.html @@ -2,7 +2,7 @@

Log in to Your Account

-
+
LDAP
@@ -13,7 +13,7 @@
- Forgot? Reset Password + Forgot? Reset Password
diff --git a/static/html/local-login.html b/static/html/local-login.html index 65689a5f..3e2834b6 100644 --- a/static/html/local-login.html +++ b/static/html/local-login.html @@ -2,7 +2,7 @@

Log in to Your Account

- +
@@ -12,7 +12,7 @@
- Forgot? Reset Password + Forgot? Reset Password
diff --git a/static/html/login.html b/static/html/login.html index 2e9af292..39a17290 100644 --- a/static/html/login.html +++ b/static/html/login.html @@ -40,7 +40,7 @@ {{ if .Register }} {{ range $c := .Links }}
- +