Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-14041] feat: do not track API key #6858

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions coprocess/proto/coprocess_session_state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,8 @@ message SessionState {
// MaxQueryDepth relates to graphQL APIs. If the session key has a maximum query depth limit defined then it is included in the
// session instance. Currently unsupported and under development.
int64 max_query_depth = 31;

// DoNotTrack is set to true to prevent the session from being tracked in the analytics.
// This is useful if there is a key which analytics are not required (e.g. health checks)
bool do_not_track = 32;
}
6 changes: 6 additions & 0 deletions gateway/handler_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ func (e *ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, errMs

oauthClientID := ""
session := ctxGetSession(r)

// If the key is configured to not track, then we don't track
if session.DoNotTrack {
return
}

tags := make([]string, 0, estimateTagsCapacity(session, e.Spec))

if session != nil {
Expand Down
6 changes: 6 additions & 0 deletions gateway/handler_success.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ func (s *SuccessHandler) RecordHit(r *http.Request, timing analytics.Latency, co
oauthClientID := ""
var alias string
session := ctxGetSession(r)

// If the key is configured to not track, then we don't track
if session.DoNotTrack {
return
}

tags := make([]string, 0, estimateTagsCapacity(session, s.Spec))
if session != nil {
oauthClientID = session.OauthClientID
Expand Down
1 change: 1 addition & 0 deletions user/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ type SessionState struct {
LastUpdated string `json:"last_updated" msg:"last_updated"`
IdExtractorDeadline int64 `json:"id_extractor_deadline" msg:"id_extractor_deadline"`
SessionLifetime int64 `bson:"session_lifetime" json:"session_lifetime"`
DoNotTrack bool `json:"do_not_track" msg:"do_not_track"`

// Used to store token hash
keyHash string
Expand Down