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-10522] Update Key API doesn't work as documented #5415

Open
jakub-bochenski opened this issue Aug 11, 2023 · 8 comments
Open

[TT-10522] Update Key API doesn't work as documented #5415

jakub-bochenski opened this issue Aug 11, 2023 · 8 comments

Comments

@jakub-bochenski
Copy link

jakub-bochenski commented Aug 11, 2023

Branch/Environment/Version

  • Branch/Version: 1.5.1
  • Environment: On-prem

Describe the bug
The API example from https://tyk.io/docs/tyk-gateway-api/ doesn't work

Reproduction steps
Add a key then try to update it

$ $ curl -X PUT -H "x-tyk-authorization: foo"   -s   -H "Content-Type: application/json" -d '{                                                                          "quota_max": 60,
  "quota_renews": 1406121006,
  "quota_renewal_rate": 60,
  "allowance": 100,
  "rate": 100,
  "per": 5,
  "org_id": "53ac07777cbb8c2d53000002"
}' http://localhost:8080/tyk/keys/9dfafcb4?hashed=true
{"status":"error","message":"Failed to create key, ensure security settings are correct."}

Actual behavior
Request fails with
{"status":"error","message":"Failed to create key, ensure security settings are correct."}

Message appears in the log:
level=error msg="Master keys disallowed in configuration, key not added."

Expected behavior
Key is updated

Configuration (tyk config file):
https://github.com/TykTechnologies/tyk-gateway-docker

@andyo-tyk
Copy link
Contributor

Hi @jakub-bochenski,
Thanks for trying Tyk!
Have you provided the correct authorization secret (the one you set as secret in your tyk.conf file) in the x-tyk-authorization header of your API request?

@jakub-bochenski
Copy link
Author

Yes I did

@andyo-tyk
Copy link
Contributor

Thanks - I'll get one of the team to take a look, to work out why it's not working for you.

@lghiur
Copy link
Member

lghiur commented Sep 6, 2023

@jakub-bochenski it looks like the payload you're using doesn't contain any access rights, and that's maybe because you want to use this key to access all APIS? If so, for this case allow_master_keys gateway configuration option needs to be enabled.

More information here: https://tyk.io/docs/tyk-oss-gateway/configuration/#allow_master_keys

Let us know if this works for you,
Thank you

@jakub-bochenski
Copy link
Author

@lghiur no, I just wanted to change some settings of the key, without changing the access rights

Is it possible to do it? Or do I have to specify all values again?
I thought the documentation showed a partial update is possible.

Having to specify all values is inconvenient. If you have two people modifying the key concurrently it will result in lost updates (unlike a patch approach)

@lghiur
Copy link
Member

lghiur commented Sep 6, 2023

@jakub-bochenski at the moment you need to provide all the access rights again, otherwise we assume that you want access to all APIs as mentioned above.

What you describe it would work more within a PATCH request indeed, but that's not supported atm.

@jakub-bochenski
Copy link
Author

OK, thanks for the clarification.

You might want to update the example in the API Docs, as I think it's misleading now

@lghiur
Copy link
Member

lghiur commented Sep 8, 2023

@jakub-bochenski thanks, I will open an internal ticket for improving docs.

@andyo-tyk andyo-tyk changed the title Update Key API doesn't work as documented [TT-10522] Update Key API doesn't work as documented Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants