Skip to content

Commit

Permalink
[ADD]param of the judgment
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaywoods2 committed Feb 18, 2017
1 parent ead83a6 commit 06985ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Folders
_obj
_test
.idea

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
1 change: 0 additions & 1 deletion _examples/cas-dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (h *myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

if r.URL.Path == "/logout" {
r.URL.Path = ""
cas.RedirectToLogout(w, r)
return
}
Expand Down
37 changes: 21 additions & 16 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (

// Client configuration options
type Options struct {
URL *url.URL // URL to the CAS service
Store TicketStore // Custom TicketStore, if nil a MemoryStore will be used
Client *http.Client // Custom http client to allow options for http connections
URL *url.URL // URL to the CAS service
Store TicketStore // Custom TicketStore, if nil a MemoryStore will be used
Client *http.Client // Custom http client to allow options for http connections
SendService bool // Custom sendService to determine whether you need to send service param
}

// Client implements the main protocol
Expand All @@ -24,8 +25,9 @@ type Client struct {
tickets TicketStore
client *http.Client

mu sync.Mutex
sessions map[string]string
mu sync.Mutex
sessions map[string]string
sendService bool
}

// NewClient creates a Client with the provided Options.
Expand All @@ -49,10 +51,11 @@ func NewClient(options *Options) *Client {
}

return &Client{
url: options.URL,
tickets: tickets,
client: client,
sessions: make(map[string]string),
url: options.URL,
tickets: tickets,
client: client,
sessions: make(map[string]string),
sendService: options.SendService,
}
}

Expand Down Expand Up @@ -114,14 +117,16 @@ func (c *Client) LogoutUrlForRequest(r *http.Request) (string, error) {
return "", err
}

service, err := requestURL(r)
if err != nil {
return "", err
}
if c.sendService {
service, err := requestURL(r)
if err != nil {
return "", err
}

q := u.Query()
q.Add("service", sanitisedURLString(service))
u.RawQuery = q.Encode()
q := u.Query()
q.Add("service", sanitisedURLString(service))
u.RawQuery = q.Encode()
}

return u.String(), nil
}
Expand Down

0 comments on commit 06985ad

Please sign in to comment.