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

Allow updating key by its hash by passing hashed=true #2056

Merged
merged 2 commits into from
Feb 3, 2019

Conversation

buger
Copy link
Member

@buger buger commented Jan 11, 2019

Works similar to how we allowed deleting key by a hash.

Fix #2055

Works similar to how we allowed deleting key by hash
@evityuk evityuk self-requested a review January 24, 2019 12:54
AdminAuth: true,
Code: 200,
BodyMatch: fmt.Sprintf(`"key":"%s"`, myKeyHash),
},
Copy link
Contributor

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?

Copy link
Member Author

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)
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tyk/api.go

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?

Copy link
Member Author

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.

@buger buger merged commit 5220853 into master Feb 3, 2019
@buger buger deleted the feature/2055-update-key-with-hash branch February 3, 2019 21:03
buger added a commit that referenced this pull request Feb 11, 2019
Works similar to how we allowed deleting key by a hash.

Fix #2055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants