-
-
Notifications
You must be signed in to change notification settings - Fork 271
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 limiting access only to short URLs created with the same API key. #795
Comments
So, let me see if I'm getting it. Your proposal is that you can make interacting with short URLs to be limited to those URLs created with the same API key, right? So that you cannot list, edit, delete or get stats for short URLs created with other API keys. Is that correct? |
yes, that's right |
I'm afraid this is currently not supported. However it looks like something nice to have. I will see how hard would be to get that. |
Sounds Great ! Thanks 😁 |
+1 for this. But I could think there should be an "admin" API (maybe the first one generated) that can see all short URLs. If this does get developed into Shlink, I'd also like to suggest that an API key can have a default domain set (at API creation) for each given API key. Example:
|
I'm thinking on a slightly different approach (mostly because this would need to be backwards compatible), which is adding a, let's call it "capability flag" to the API keys, where you tell if they are limited to interactions with short URLs created with them only, or instead, they can be used for any short URL, as it works now, being the latter its default behavior. On regards to domains, I think that would be a different feature that could be used together with the one discussed here or independently. So basically, you could define:
Each "capability" would be added/removed separately to/from the API key. Other than this, there are questions to answer regarding tags, both for domain-based limits and creation-based limits.
In both cases I would say yes, but I'm open to feedback here. |
I think that's a solid approach.
I'd concur. Yes to both. |
Hey @antwonw @rubenmdh @captainAldi. I'm pinging you as you have been involved in this thread or reacted to some of the comments. I have been working on this feature and I'm more or less half-way there. I have managed to sort the hard part, which is deciding how to approach the issue in a maintainable and future-proof way, and I'm now applying it to all the endpoints that require the extra permission checks. I will most probably release an alpha version this comming week, containing this feature. I will drop a message here once it's released. Since the changes are deep, if any of you could test it, it would be great. In the meantime I will close a few minor tasks that I want to release with v2.5 There's no need to agree to anything. I will just drop the message here, and whoever can test the alpha version, it's perfect. If by the time I have finished working on the rest of the tickets for v2.5 milestone nobody brought up any issues, I will release it as stable. In any case, I expect at least one patch for v2.5 to be needed, fixing missbehaviors on this feature, or regressions on others. |
I am willing to test it as soon as you are ready to release the alpha version. Looking forward to it :) |
Amazing. Thanks @rubenmdh 🙂 |
that's great, will test it when available 😁 |
Hey! I have just published shlink v2.5.0-alpha.2 (the docker image is getting built), which includes the new feature to restrict access to API keys based on the short URLs they created or one domain. The feature is implemented as described in this comment above, but you can also see the full checklist of things that have been implemented in this issue It also includes a list of considerations that I will copy here. These are some things I have left out in order to simplify this (as it's quite big already), but also things that cannot be done because of how shlink is architected.
The interaction with API keys is still done from the CLI. The You can run them with And that's more or less it. Give it a try and let me know if the feature is working more or less as you expected and I didn't mess up too much 😅. In the meantime I'll continue with the checklist in #882, as this still needs to be documented and I also want to do some load tests. |
It seems I'm the first one! It works fine on my server. |
Hey @rubenmdh, thanks a lot for spending some time testing it.
Yes, exactly. Anyone should be able to update to this version and everything should continue working the same.
This is more or less related with backwards compatibility too. However, I may give the option to customize the default behavior. Probably on a future version.
I'm not sure what you mean by this. Do you mean that, when listing short URLs with an admin API key, you should be able to see the author API key? |
Exactly, this is what I meant. |
Ok, got it. Sadly, that's a bit tricky. The fact that you cannot interact with API keys through the API, is intended, for security reasons. Having now other endpoints return API keys arbitrarily would have a lot of security considerations. They could of course be masked, by using a neme/title for every API key, but that's a bit cumbersome while managing API keys. So I'm afraid I won't add this to API endpoints. However, I could consider extending CLI commands to include extra info. |
Shlink v2.5.0 is being built and will be released any time. The docs for API key roles are already available here https://shlink.io/documentation/api-docs/api-key-roles/ |
Summary
Hello, there is a feature like different api key and then differenct short link they have ?
cause i dont see it in documentation
and if not it will be great if there is
i mean, now the api key that i made for the same domain it's still can seeing the other url with different api key
it's possible ?
Thanks before
The text was updated successfully, but these errors were encountered: