Skip to content

Commit

Permalink
Merge pull request #9 from carllhw/feature-cas-url
Browse files Browse the repository at this point in the history
Add support for CAS server URLs without a trailing slash, fixes the login/logout and other route generation.
  • Loading branch information
geoffgarside committed Feb 17, 2017
2 parents fd85b5a + 6988ce4 commit 74a3eae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ _testmain.go
*.exe
*.test
*.prof

.vscode
9 changes: 5 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"path"
"sync"

"github.com/golang/glog"
Expand Down Expand Up @@ -90,7 +91,7 @@ func requestURL(r *http.Request) (*url.URL, error) {

// LoginUrlForRequest determines the CAS login URL for the http.Request.
func (c *Client) LoginUrlForRequest(r *http.Request) (string, error) {
u, err := c.url.Parse("login")
u, err := c.url.Parse(path.Join(c.url.Path, "login"))
if err != nil {
return "", err
}
Expand All @@ -109,7 +110,7 @@ func (c *Client) LoginUrlForRequest(r *http.Request) (string, error) {

// LogoutUrlForRequest determines the CAS logout URL for the http.Request.
func (c *Client) LogoutUrlForRequest(r *http.Request) (string, error) {
u, err := c.url.Parse("logout")
u, err := c.url.Parse(path.Join(c.url.Path, "logout"))
if err != nil {
return "", err
}
Expand All @@ -119,7 +120,7 @@ func (c *Client) LogoutUrlForRequest(r *http.Request) (string, error) {

// ServiceValidateUrlForRequest determines the CAS serviceValidate URL for the ticket and http.Request.
func (c *Client) ServiceValidateUrlForRequest(ticket string, r *http.Request) (string, error) {
u, err := c.url.Parse("serviceValidate")
u, err := c.url.Parse(path.Join(c.url.Path, "serviceValidate"))
if err != nil {
return "", err
}
Expand All @@ -139,7 +140,7 @@ func (c *Client) ServiceValidateUrlForRequest(ticket string, r *http.Request) (s

// ValidateUrlForRequest determines the CAS validate URL for the ticket and http.Request.
func (c *Client) ValidateUrlForRequest(ticket string, r *http.Request) (string, error) {
u, err := c.url.Parse("validate")
u, err := c.url.Parse(path.Join(c.url.Path, "validate"))
if err != nil {
return "", err
}
Expand Down

0 comments on commit 74a3eae

Please sign in to comment.