Skip to content

Commit

Permalink
obfuscateKey should respect EnableKeyLogging
Browse files Browse the repository at this point in the history
Fix #1826
  • Loading branch information
buger committed Aug 9, 2018
1 parent 5d6cd02 commit 0286a44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 0 additions & 7 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,6 @@ func doAddOrUpdate(keyName string, newSession *user.SessionState, dontReset bool
return nil
}

func obfuscateKey(keyName string) string {
if len(keyName) > 4 {
return "****" + keyName[len(keyName)-4:]
}
return "--"
}

// ---- TODO: This changes the URL structure of the API completely ----
// ISSUE: If Session stores are stored with API specs, then managing keys will need to be done per store, i.e. add to all stores,
// remove from all stores, update to all stores, stores handle quotas separately though because they are localised! Keys will
Expand Down
11 changes: 11 additions & 0 deletions log_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ import (
// identifies that field value was hidden before output to the log
const logHiddenValue = "<hidden>"

func obfuscateKey(keyName string) string {
if config.Global().EnableKeyLogging {
return keyName
}

if len(keyName) > 4 {
return "****" + keyName[len(keyName)-4:]
}
return "--"
}

func getLogEntryForRequest(r *http.Request, key string, data map[string]interface{}) *logrus.Entry {
// populate http request fields
fields := logrus.Fields{
Expand Down

0 comments on commit 0286a44

Please sign in to comment.