-
Notifications
You must be signed in to change notification settings - Fork 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
API key enhancements #14489
API key enhancements #14489
Conversation
I think that's an idea we need to discuss separately, can you move that change into a separate PR ? Maybe also outline why this would be needed, what the usecase is (keep in mind we have no way to give a different set of permissions to API keys, which is what you'd use multiple api keys or tokens for) |
Sure, I'll make a new PR and put changes related to multiple keys there. With having different permissions, this feature is even more helpful(any plan/issue/pr?). Still, even without it, the user can have other keys for various projects and, if needed, and if one of them must be deleted, there is no need to change all the project keys (each key should have a description or name). |
... at which point you need to regenerate all of them, since you can generate sessions and look at other API keys or even create new ones. Essentially having one would equate to having all keys. We can work around that, but then we've halfway implemented token scopes, and I think we'd be better off doing that properly. |
xref: #1524 |
I agree with you. I read the mentioned issue, and we can discuss it later. |
ba29028
to
8e46678
Compare
7f36340
to
7cf6ac4
Compare
Are the |
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.
So removing one API key will obviously just show the next available one.
That's problematic, I suggest we mark all old keys as deleted.
I would not change the return value for API keys, I don't think we'll introduce "scoped" api keys, this should use a different infrastructure for generating tokens, with a different endpoint.
Thanks for having a look Marius!
Ok, that makes sense. So then, do you mean we should return the API key as plain text instead of the model with Please note that the old API was dealing with lists of APIKeys too, just it always returned the [0] index of the list which is what we are doing in What about the
The APIKeys database model doesn't have a |
Yes, we should add this column if we really want to delete API keys (as opposed to generating a new API key). We can't delete a key and then activate an old API key, that's a no-go (say you've created a new API key after exposing the old one in a screencast or similar, now the next time you delete an API key the leaked API key will be valid). This wasn't previously a problem, because we'd just generate a new one. Which, to me, was absolutely fine.
I agree it looks nice, but I don't think it's worth breaking backwards compatibility over this. In fact I don't think we should even change the GET being a get-or-create, cause again, people may rely on this. Maybe put the new behavior under
That's fine with me, I doubt they've been used in scripts. |
da1a666
to
5bd74c9
Compare
The existing endpoints will return the API key as a plain string and the `GET /api/users/{user_id}/api_key` route will get or create the key as it used to be.
This will make sure any user with multiple created keys will mark them as deleted as soon as the first one is deleted.
Galaxy and the ToolShed have duplicated APIKeys models and the ApiKeyManager can be used from both apps
Since the toolshed uses a duplicated `api_keys` table we sadly need to duplicate the migration too...
6fa7448
to
fd299bd
Compare
This one should be ready to go :) |
I'm not sure I understand the use case for adding the |
It's for auditing, and the logic problem of just using the previous key, which will fall back to an old key of you just straight up delete the API key from the database. The alternative is a migration that drops all non-latest keys, but I am unsure if that is really the best approach. |
If it's for auditing then I think it's fine, thanks! |
This PR was merged without a "kind/" label, please correct. |
Closes #13328 and Closes #10742
This pr migrates the API key endpoint to Fast API, vuetify the client, and the user can mark the API key as deleted.
API changes
We made some retro-compatible API changes around the API key management endpoints:
APIKeys
model now has adeleted
column. It has been added to the galaxy model and the toolshed model.GET /api/users/{id}/api_key/inputs
that returned additional data for rendering the API key in the UI.PUT /api/users/{id}/api_key/inputs
that created a new API key and returned data for rendering the UI.GET /api/users/{id}/api_key/detailed
that now returns theAPIKeyModel
or 204 status code if there's no key.DELETE /api/users/{user_id}/api_key
to delete/revoke (all*) current API key.Important Note (*): Since the old button to generate an API was always enabled, a user might have multiple API keys in the database if it was used multiple times. Deleting the API key will mark all existing API keys as deleted.
How to test the changes?
(Select all options that apply)
License