diff --git a/.gitignore b/.gitignore index 5f5e339..9b9a5a3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # Folders _obj _test +.idea # Architecture specific extensions/prefixes *.[568vq] diff --git a/client.go b/client.go index 116214f..7a550d1 100644 --- a/client.go +++ b/client.go @@ -14,9 +14,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 @@ -25,8 +26,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. @@ -50,10 +52,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, } } @@ -115,6 +118,17 @@ func (c *Client) LogoutUrlForRequest(r *http.Request) (string, error) { 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() + } + return u.String(), nil }