-
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 16.15% 16.16%
- Complexity 13263 13282 +19
==========================================
Files 5666 5676 +10
Lines 497960 498848 +888
Branches 60241 60295 +54
==========================================
+ Hits 80459 80634 +175
- Misses 408499 409192 +693
- Partials 9002 9022 +20
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
Outdated
Show resolved
Hide resolved
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
@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 10714 |
@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 10720 |
@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 10736 |
@blueorangutan test |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian Build Failed (tid-12305) |
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
e8e3f7f
to
03754f6
Compare
CONSTRAINT `fk_api_keypair__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `cloud`.`domain`(`id`) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS `cloud`.`keypair_permissions` ( |
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.
to avoid confusion, may be better to use api_keypair_permissions
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
03754f6
to
ff396b1
Compare
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
ff396b1
to
aa7c0d5
Compare
@blueorangutan package |
@nicoschmdt 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 12501 |
sorry @nicoschmdt , you missed some double imports:
|
@blueorangutan package |
@nicoschmdt 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 12505 |
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