-
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
Api keypair restructure #9504
base: main
Are you sure you want to change the base?
Api keypair restructure #9504
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9504 +/- ##
==========================================
Coverage 15.78% 15.78%
- Complexity 12565 12578 +13
==========================================
Files 5627 5637 +10
Lines 492260 493125 +865
Branches 63882 63301 -581
==========================================
+ Hits 77710 77857 +147
- Misses 406076 406781 +705
- Partials 8474 8487 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
nice feature @KlausDornsbach , some suggestions,
|
Hey @DaanHoogland, thanks for taking a look! It would make sense to be able to delete a keypair by name, we would just need to block users from creating multiple API keypairs with the same name. At the moment an admin is allowed to delete keypairs from users it has access, for example, a root admin user could delete any keypair in the platform, domain admin users can delete any keypair in the domain, normal users can only delete their own keys. These permissions are also true for visualization and creation APIs. |
Well, I think a unique constraint on UserId/KeyPairName makes sense also from a usability sense.
👍 |
@blueorangutan package |
api/src/main/java/org/apache/cloudstack/api/command/admin/user/ListUserKeysCmd.java
Outdated
Show resolved
Hide resolved
engine/schema/src/main/java/org/apache/cloudstack/acl/ApiKeyPairPermissionVO.java
Show resolved
Hide resolved
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11204 |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-11556)
|
Hey guys, looking at the Marvin test logs I have found the following error
Which indicates the API is outputting an error with the message is it possible blueorangutang is basing tests on an older commit? |
by the looks of the history of comments in PR, I'd say no, @KlausDornsbach . Let me redo it once |
@blueorangutan package |
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11241 |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-11579)
|
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.
Creating multiple key pairs works fine
Deletion of keypair works fine
registerUserKeys creates keypair in disabled state, is this expected? How to change the state to enabled?
Able to set validity
Is there a way to update user keys, such as updating the enddate, rules etc.. ?
Creating rule works fine in general but rule with asterisk fails.
(PR-9504) 🐱 > register userkeys id=55cde672-3fd4-4670-95f2-4a88513d9d05 name=jithin-test-rules description=jithin-test-rules startdate=2024-10-08 enddate=2024-10-10 rules[1].rule=list* rules[1].permission=allow
🙈 Error: (HTTP 431, error code 4350) API list* was not found on the user's account, a valid keypair rule must be also present at the account level
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
@blueorangutan package |
@rajujith a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 11389 |
@KlausDornsbach , can you have a look at these?
It seems there are some unit test failures. |
Hey guys, I have fixed the tests. Also, answering the first question @rajujith
@DaanHoogland,
|
@blueorangutan package |
@rajujith a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11425 |
Description
API access keypairs are primarily used to support interactions between systems, without the need to create sessions (through user and password authentication). Currently, CloudStack's implementation of API keypairs does not allow you to specify permissions for each keypair, simply using the account's default permissions. Additionally, the number of keypairs is limited to one per user and they have no start and end dates.
An extension of the API keypairs functionality was implemented, adding several new features that increase flexibility and security. It is now possible to specify a subset of permissions (from the base account) for each keypair, as well as create more than one key per user. It is also possible to define start and end dates for the validity of a keypair. A key created without an expiration date will always be valid up until it is deleted. It should be noted that creating API keypairs without specifying permissions just creates an API keypair with all account's base permissions. Also, API keypairs older than this patch will always be viewed as keypairs with full account permissions.
The following endpoints were created:
A new
listUserKeys
API was added. Through this API the user will be able to specify a singlekeypairid
to fetch its specific properties, orapikeyfilter
to return a specific keypair based on anapikey
. The user can inform anuserid
to fetch an user's api keypair list. If nokeypairid
,apikeyfilter
oruserid
is provided, the API defaults to fetching information on the calling user. Thelistall
property allows for fetching all keypairs in the structure that are visible based on the calling user/keypair permissions, if not specified, it defaults to false, fetching only the apikeys on the level of the calling user/keypair. Also, it is possible to informshowpermissions
to list all permissions associated with each returnedapikey
.The API
getUserKeys
was modified preserving backwards compatibility. It now fetches the last keypair created for the informed user.The api
registerUserKeys
was modified so the new API keypair parameters could be specified on creation:A new keypair deletion API was added (
deleteUserKeys
). It will accept only one required argument, the keypairid
.I also added a
listUserKeyRules
api, allowing the user to list the rules associated with an API keypair.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
How Has This Been Tested?
API Key Creation and Basic Testing
Single Key (via UI):
Multiple Keys (via Cloud Monkey):
Permissions Validation
Tested the permissions of keyrules listing, keypair listing, keypair deletion and keypair cretion with the following user/account/domain setup:
/ROOT
account
root admin
root admin
user1
domain
subdomain
domain admin
domain admin
userAccount
user2
user3
The following table describes the results obtained when the user on the first column attempted to operate on the keypairs of users on the first row (V: operation was possible, F: operation was not possible).
Migration to
api_keypair
Table4.19
to4.20
api_keypair
table, with the corresponding columns in the user table deleted.General validations