Skip to content

Commit

Permalink
Merge branch 'master' into remove-ratelimit-session-update
Browse files Browse the repository at this point in the history
  • Loading branch information
buger committed Jun 13, 2018
2 parents 47b8d60 + cf3c47b commit ae0bbde
Show file tree
Hide file tree
Showing 12 changed files with 546 additions and 173 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
Tyk is a lightweight, open source API Gateway and Management Platform enables you to control who accesses your API, when they access it and how they access it. Tyk will
also record detailed analytics on how your users are interacting with your API and when things go wrong.

Go version 1.8 or later is required to build `master`, the current
Go version 1.9 is required to build `master`, the current
development version. Tyk is officially supported on `linux/amd64`,
`linux/i386` and `linux/arm64`.

Tests are run against both Go versions 1.9 & 1.10, however at present, only Go 1.9 is officially supported.

## What is an API Gateway?

An API Gateway sits in front of your application(s) and manages the heavy lifting of authorisation, access control and throughput limiting to your services. Ideally,
Expand Down
24 changes: 16 additions & 8 deletions coprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,8 @@ func (c *CoProcessor) ObjectFromRequest(r *http.Request) *coprocess.Object {
if c.HookType != coprocess.HookType_Pre && c.HookType != coprocess.HookType_CustomKeyCheck {
if session := ctxGetSession(r); session != nil {
object.Session = ProtoSessionState(session)
// If the session contains metadata, add items to the object's metadata map:
if len(session.MetaData) > 0 {
object.Metadata = make(map[string]string)
for k, v := range session.MetaData {
object.Metadata[k] = v.(string)
}
}
// For compatibility purposes:
object.Metadata = object.Session.Metadata
}
}

Expand Down Expand Up @@ -278,7 +273,20 @@ func (m *CoProcessMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Requ

coProcessor.ObjectPostProcess(returnObject, r)

token := returnObject.Metadata["token"]
var token string
if returnObject.Session != nil {
// For compatibility purposes, inject coprocess.Object.Metadata fields:
if returnObject.Metadata != nil {
if returnObject.Session.Metadata == nil {
returnObject.Session.Metadata = make(map[string]string)
}
for k, v := range returnObject.Metadata {
returnObject.Session.Metadata[k] = v
}
}

token = returnObject.Session.Metadata["token"]
}

// The CP middleware indicates this is a bad auth:
if returnObject.Request.ReturnOverrides.ResponseCode > 400 {
Expand Down
67 changes: 58 additions & 9 deletions coprocess/bindings/python/coprocess_session_state_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion coprocess/bindings/ruby/coprocess_session_state_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ae0bbde

Please sign in to comment.