Commit 435cadfc authored by Eric Chiang's avatar Eric Chiang

*: more updates to prepend the correct API path

parent ede6300a
......@@ -16,6 +16,7 @@ import (
"net/http"
"net/url"
"os"
"path"
"strings"
"time"
......@@ -181,7 +182,7 @@ func NewClientHandler(c *oidc.Client, issuer string, cbURL url.URL) http.Handler
}
resendURL := *issuerURL
resendURL.Path = "/resend-verify-email"
resendURL.Path = path.Join(resendURL.Path, "/resend-verify-email")
mux.HandleFunc("/resend", handleResendFunc(c, *issuerURL, resendURL, cbURL))
return mux
......
......@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"path"
"strings"
"github.com/coreos/dex/connector"
......@@ -336,7 +337,7 @@ func getConnectorForUserByEmail(ur user.UserRepo, email string) (string, error)
func newLoginURLFromSession(issuer url.URL, ses *session.Session, register bool, connectorFilter []string, msgCode string) *url.URL {
loginURL := issuer
v := loginURL.Query()
loginURL.Path = httpPathAuth
loginURL.Path = path.Join(loginURL.Path, httpPathAuth)
v.Set("redirect_uri", ses.RedirectURL.String())
v.Set("state", ses.ClientState)
v.Set("client_id", ses.ClientID)
......
......@@ -8,6 +8,7 @@ import (
"net/url"
"path"
"sort"
"strings"
"time"
"github.com/coreos/go-oidc/jose"
......@@ -215,7 +216,13 @@ func (s *Server) HTTPHandler() http.Handler {
clock := clockwork.NewRealClock()
mux := http.NewServeMux()
handle := func(urlPath string, h http.Handler) {
mux.Handle(path.Join(s.IssuerURL.Path, urlPath), h)
p := path.Join(s.IssuerURL.Path, urlPath)
// path.Join always trims trailing slashes (https://play.golang.org/p/GRr0jDd9P7).
// If path being registered has a trailing slash, add it back on.
if strings.HasSuffix(urlPath, "/") {
p = p + "/"
}
mux.Handle(p, h)
}
handleFunc := func(urlPath string, hf http.HandlerFunc) {
handle(urlPath, hf)
......@@ -277,7 +284,7 @@ func (s *Server) HTTPHandler() http.Handler {
}
// NOTE(ericchiang): This path MUST end in a "/" in order to indicate a
// path prefix rather than an absolute path.
mux.Handle(path.Join(httpPathAuth, idpc.ID())+"/", idpc.Handler(*errorURL))
handle(path.Join(httpPathAuth, idpc.ID())+"/", idpc.Handler(*errorURL))
}
apiBasePath := path.Join(httpPathAPI, APIVersion)
......
......@@ -15,7 +15,7 @@
{{ end }}
{{ else }}
<h2 class="heading">Reset your password</h2>
<form onsubmit="return validate();" id="resetPasswordForm" method="POST" action="/reset-password">
<form onsubmit="return validate();" id="resetPasswordForm" method="POST" action="{{ "/reset-password" | absPath }}">
<div class="form-row">
<div class="input-desc">
<label for="password">New Password</label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment