-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow updating key by its hash by passing hashed=true #2056
Conversation
Works similar to how we allowed deleting key by hash
AdminAuth: true, | ||
Code: 200, | ||
BodyMatch: fmt.Sprintf(`"key":"%s"`, myKeyHash), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any swagger doc updates required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, added note to ticket about swagger (it already had "needs documenting" label).
But in general, in future, it makes sense move swagger file from docs repository to Tyk repository.
@@ -669,7 +673,7 @@ func keyHandler(w http.ResponseWriter, r *http.Request) { | |||
|
|||
switch r.Method { | |||
case "POST", "PUT": | |||
obj, code = handleAddOrUpdate(keyName, r) | |||
obj, code = handleAddOrUpdate(keyName, r, isHashed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side-effect you now allows to create a hashed key from scratch.
This is no problem, but makes sense to document it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to group isHashed&keyName to separate viewModel like structure:
type KeyInfo struct { keyName string isHashed string }
in order to reduce the number of function params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 662 in 352f98c
isHashed := r.URL.Query().Get("hashed") != "" |
When
hashed
is set explicitly to false(eg: ?hashed=false) then currently the value will be considered as set to true
.Does it makes sense to support(considering other apis and their treatment of boolean query params) or is it by design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at analytics code we messed up this param previously, and in some places it use "1" and in some "true", so for backward compatibility reasons we have to keep it like this.
Works similar to how we allowed deleting key by a hash. Fix #2055
Works similar to how we allowed deleting key by a hash.
Fix #2055