Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
216d2691
Commit
216d2691
authored
Jul 22, 2016
by
Eric Chiang
Committed by
GitHub
Jul 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #520 from squat/add-absolute-path-to-templates
backend: add absolute path to template links
parents
1759b960
0cc0c736
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
15 deletions
+25
-15
config.go
server/config.go
+12
-2
testutil_test.go
server/testutil_test.go
+1
-1
ldap-login.html
static/html/ldap-login.html
+2
-2
local-login.html
static/html/local-login.html
+2
-2
login.html
static/html/login.html
+4
-4
register.html
static/html/register.html
+3
-3
send-reset-password.html
static/html/send-reset-password.html
+1
-1
No files found.
server/config.go
View file @
216d2691
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"io"
"io"
"net/url"
"net/url"
"os"
"os"
"path"
"path/filepath"
"path/filepath"
texttemplate
"text/template"
texttemplate
"text/template"
"time"
"time"
...
@@ -63,7 +64,7 @@ func (cfg *ServerConfig) Server() (*Server, error) {
...
@@ -63,7 +64,7 @@ func (cfg *ServerConfig) Server() (*Server, error) {
return
nil
,
err
return
nil
,
err
}
}
tpl
,
err
:=
getTemplates
(
cfg
.
IssuerName
,
cfg
.
IssuerLogoURL
,
cfg
.
EnableRegistration
,
cfg
.
TemplateDir
)
tpl
,
err
:=
getTemplates
(
cfg
.
IssuerName
,
cfg
.
Issuer
URL
,
cfg
.
Issuer
LogoURL
,
cfg
.
EnableRegistration
,
cfg
.
TemplateDir
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -281,8 +282,14 @@ func (cfg *MultiServerConfig) Configure(srv *Server) error {
...
@@ -281,8 +282,14 @@ func (cfg *MultiServerConfig) Configure(srv *Server) error {
return
nil
return
nil
}
}
func
getTemplates
(
issuerName
,
issuerLogoURL
string
,
func
getTemplates
(
issuerName
,
issuer
URL
,
issuer
LogoURL
string
,
enableRegister
bool
,
dir
string
)
(
*
template
.
Template
,
error
)
{
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
{}{
tpl
:=
template
.
New
(
""
)
.
Funcs
(
map
[
string
]
interface
{}{
"issuerName"
:
func
()
string
{
"issuerName"
:
func
()
string
{
return
issuerName
return
issuerName
...
@@ -293,6 +300,9 @@ func getTemplates(issuerName, issuerLogoURL string,
...
@@ -293,6 +300,9 @@ func getTemplates(issuerName, issuerLogoURL string,
"enableRegister"
:
func
()
bool
{
"enableRegister"
:
func
()
bool
{
return
enableRegister
return
enableRegister
},
},
"absPath"
:
func
(
p
string
)
string
{
return
path
.
Join
(
issuerPath
,
p
)
},
})
})
return
tpl
.
ParseGlob
(
dir
+
"/*.html"
)
return
tpl
.
ParseGlob
(
dir
+
"/*.html"
)
...
...
server/testutil_test.go
View file @
216d2691
...
@@ -230,7 +230,7 @@ func makeTestFixturesWithOptions(options testFixtureOptions) (*testFixtures, err
...
@@ -230,7 +230,7 @@ func makeTestFixturesWithOptions(options testFixtureOptions) (*testFixtures, err
return
nil
,
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"
,
"https://coreos.com/assets/images/brand/coreos-mark-30px.png"
,
true
,
templatesLocation
)
true
,
templatesLocation
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
static/html/ldap-login.html
View file @
216d2691
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"panel"
>
<div
class=
"panel"
>
<h2
class=
"heading"
>
Log in to Your Account
</h2>
<h2
class=
"heading"
>
Log in to Your Account
</h2>
<form
method=
"post"
action=
"{{.PostURL}}"
>
<form
method=
"post"
action=
"{{.PostURL
| absPath
}}"
>
<div
class=
"form-row"
>
<div
class=
"form-row"
>
LDAP
LDAP
<div
class=
"input-desc"
>
<div
class=
"input-desc"
>
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<div
class=
"input-desc"
>
<div
class=
"input-desc"
>
<label
for=
"password"
>
Password
</label>
<label
for=
"password"
>
Password
</label>
<span
class=
"subtle-text input-label-right"
>
Forgot?
<a
href=
"
/send-reset-password
?session_key={{ .SessionKey }}"
>
Reset Password
</a></span>
<span
class=
"subtle-text input-label-right"
>
Forgot?
<a
href=
"
{{ "
/
send-reset-password
"
|
absPath
}}
?
session_key=
{{
.
SessionKey
}}"
>
Reset Password
</a></span>
</div>
</div>
<input
tabindex=
"2"
required
id=
"password"
name=
"password"
type=
"password"
class=
"input-box"
placeholder=
"password"
/>
<input
tabindex=
"2"
required
id=
"password"
name=
"password"
type=
"password"
class=
"input-box"
placeholder=
"password"
/>
</div>
</div>
...
...
static/html/local-login.html
View file @
216d2691
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"panel"
>
<div
class=
"panel"
>
<h2
class=
"heading"
>
Log in to Your Account
</h2>
<h2
class=
"heading"
>
Log in to Your Account
</h2>
<form
method=
"post"
action=
"{{.PostURL}}"
>
<form
method=
"post"
action=
"{{.PostURL
| absPath
}}"
>
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<div
class=
"input-desc"
>
<div
class=
"input-desc"
>
<label
for=
"userid"
>
Email Address
</label>
<label
for=
"userid"
>
Email Address
</label>
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<div
class=
"input-desc"
>
<div
class=
"input-desc"
>
<label
for=
"password"
>
Password
</label>
<label
for=
"password"
>
Password
</label>
<span
class=
"subtle-text input-label-right"
>
Forgot?
<a
href=
"
/send-reset-password
?session_key={{ .SessionKey }}"
>
Reset Password
</a></span>
<span
class=
"subtle-text input-label-right"
>
Forgot?
<a
href=
"
{{ "
/
send-reset-password
"
|
absPath
}}
?
session_key=
{{
.
SessionKey
}}"
>
Reset Password
</a></span>
</div>
</div>
<input
tabindex=
"2"
required
id=
"password"
name=
"password"
type=
"password"
class=
"input-box"
placeholder=
"password"
/>
<input
tabindex=
"2"
required
id=
"password"
name=
"password"
type=
"password"
class=
"input-box"
placeholder=
"password"
/>
</div>
</div>
...
...
static/html/login.html
View file @
216d2691
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
{{ if .Register }}
{{ if .Register }}
{{ range $c := .Links }}
{{ range $c := .Links }}
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<a
href=
"{{ $c.URL }}"
target=
"_self"
>
<a
href=
"{{ $c.URL
| absPath
}}"
target=
"_self"
>
<button
class=
"btn btn-provider"
>
<button
class=
"btn btn-provider"
>
<span
class=
"btn-icon btn-icon-{{ $c.ID }}"
></span>
<span
class=
"btn-icon btn-icon-{{ $c.ID }}"
></span>
<span
class=
"btn-text"
>
Use {{ $c.DisplayName }}
</span>
<span
class=
"btn-text"
>
Use {{ $c.DisplayName }}
</span>
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
{{ else }}
{{ else }}
{{ range $c := .Links }}
{{ range $c := .Links }}
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<a
href=
"{{ $c.URL }}"
target=
"_self"
>
<a
href=
"{{ $c.URL
| absPath
}}"
target=
"_self"
>
<button
class=
"btn btn-provider"
>
<button
class=
"btn btn-provider"
>
<span
class=
"btn-icon btn-icon-{{ $c.ID }}"
></span>
<span
class=
"btn-icon btn-icon-{{ $c.ID }}"
></span>
<span
class=
"btn-text"
>
Log in with {{ $c.DisplayName }}
</span>
<span
class=
"btn-text"
>
Log in with {{ $c.DisplayName }}
</span>
...
@@ -68,10 +68,10 @@
...
@@ -68,10 +68,10 @@
{{ if not .Error }}
{{ if not .Error }}
<div
class=
"footer subtle-text"
>
<div
class=
"footer subtle-text"
>
{{ if .Register }}
{{ if .Register }}
Already have an account?
<a
href=
"{{ .RegisterOrLoginURL }}"
>
Log in
</a>
Already have an account?
<a
href=
"{{ .RegisterOrLoginURL
| absPath
}}"
>
Log in
</a>
{{ else }}
{{ else }}
{{ if enableRegister }}
{{ if enableRegister }}
Don't have an account yet?
<a
href=
"{{ .RegisterOrLoginURL }}"
>
Register
</a>
Don't have an account yet?
<a
href=
"{{ .RegisterOrLoginURL
| absPath
}}"
>
Register
</a>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</div>
</div>
...
...
static/html/register.html
View file @
216d2691
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
If you'd like to login with that account, click here:
If you'd like to login with that account, click here:
</div>
</div>
<div>
<div>
<a
href=
"{{ .Login }}"
target=
"_self"
>
<a
href=
"{{ .Login
| absPath
}}"
target=
"_self"
>
<button
class=
"btn btn-provider"
>
<button
class=
"btn btn-provider"
>
<span
class=
"btn-text"
>
Login
</span>
<span
class=
"btn-text"
>
Login
</span>
</button>
</button>
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
If you would like to register with a different account, click here:
If you would like to register with a different account, click here:
</div>
</div>
<div>
<div>
<a
href=
"{{ .Register }}"
target=
"_self"
>
<a
href=
"{{ .Register
| absPath
}}"
target=
"_self"
>
<button
class=
"btn btn-provider"
>
<button
class=
"btn btn-provider"
>
<span
class=
"btn-text"
>
Register
</span>
<span
class=
"btn-text"
>
Register
</span>
</button>
</button>
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
{{ else }}
{{ else }}
<form
id=
"registerForm"
method=
"POST"
action=
"/register
"
>
<form
id=
"registerForm"
method=
"POST"
action=
"{{ "
/
register
"
|
absPath
}}
"
>
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<div
class=
"input-desc"
>
<div
class=
"input-desc"
>
...
...
static/html/send-reset-password.html
View file @
216d2691
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<h2
class=
"heading"
>
Reset your password
</h2>
<h2
class=
"heading"
>
Reset your password
</h2>
<div
class=
"explain"
>
We will send you an email with a link to reset your password.
</div>
<div
class=
"explain"
>
We will send you an email with a link to reset your password.
</div>
<form
id=
"sendResetPasswordForm"
method=
"POST"
action=
"
/send-reset-password
"
>
<form
id=
"sendResetPasswordForm"
method=
"POST"
action=
"
{{ "
/
send-reset-password
"
|
absPath
}}
"
>
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<div
class=
"input-desc"
>
<div
class=
"input-desc"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment