Skip to content

Commit

Permalink
Added cookie based support
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Aug 4, 2015
1 parent 2b1490e commit 8223692
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions middleware_auth_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func (k *AuthKey) ProcessRequest(w http.ResponseWriter, r *http.Request, configu
authHeaderValue = tempRes.FormValue(thisConfig.AuthHeaderName)
}

if thisConfig.UseCookie {
tempRes := CopyRequest(r)
authCookie, notFoundErr := tempRes.Cookie(thisConfig.AuthHeaderName)
if notFoundErr != nil {
authHeaderValue = ""
} else {
authHeaderValue = authCookie.Value
}
}

if authHeaderValue == "" {
// No header value, fail
log.WithFields(logrus.Fields{
Expand Down
6 changes: 5 additions & 1 deletion middleware_virtual_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ func (d *VirtualEndpoint) ServeHTTPForCache(w http.ResponseWriter, r *http.Reque
// ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
func (d *VirtualEndpoint) ProcessRequest(w http.ResponseWriter, r *http.Request, configuration interface{}) (error, int) {

d.ServeHTTPForCache(w, r)
res := d.ServeHTTPForCache(w, r)

if res == nil {
return nil, 200
}

return nil, 666
}
Expand Down

0 comments on commit 8223692

Please sign in to comment.