You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "bernardodemarco (via GitHub)" <gi...@apache.org> on 2026/05/22 19:17:40 UTC
[PR] UI for API Key Pair Management [cloudstack]
bernardodemarco opened a new pull request, #13225:
URL: https://github.com/apache/cloudstack/pull/13225
### Description
PR #9504 restructured and extended the implementation of API key pairs to improve flexibility and security. It is now possible to create multiple key pairs per user, define a specific permission scope for each key pair and specify a validation period during which they remain active.
This PR exposes these new features in the ACS graphical interface. Among the new functionalities, users can now list all key pairs associated with a user, view their details and permissions, and register new key pairs with validity periods and permission sets.
Additionally, some minor fixes and enhancements were introduced to the API key pair backend workflows, including:
- Default roles `Domain Admin`, `Resource Admin` and `User` were granted access to the `listUserKeyRules` API;
- The type of the `description` column of the `cloud.api_keypair` table was changed from `VARCHAR(100)` to `VARCHAR(1024)`; and,
- The type of the `description` column of the `cloud.api_keypair_permissions` table is `VARCHAR(255)`. However, the `registerUserKeys` API currently do not validate the size of the corresponding API parameter. This validation has been introduced.
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] Build/CI
- [ ] Test (unit or integration test code)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [X] Major
- [ ] Minor
### Screenshots (if appropriate):
https://github.com/user-attachments/assets/e71ae203-88ae-44e5-8a6e-9069415a4a54
### How Has This Been Tested?
The new UI sections were manually tested and their behavior was verified accordingly.
To test this patch, the backend must include PR #9504.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "daviftorres (via GitHub)" <gi...@apache.org>.
daviftorres commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4554738083
Dear @bernardodemarco , this is excellent!
I saw in the recording that keys can be added and removed, and that the allow/deny rules are set when the key is created.
Is it possible to later add, remove, or modify the rules for an existing key, or do you need to create a new key each time you want to change the rules?
Regards,
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4660910417
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18205
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "bernardodemarco (via GitHub)" <gi...@apache.org>.
bernardodemarco commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3304197018
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,455 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :key="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @handle-cancel="handleCancelAddKeyPair"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+import store from '@/store'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair,
+ store
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
Review Comment:
If the parameter is specified by an account that does not have access to it, ACS will simply ignore the parameter. It will not bring any side effects
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4523452988
UI build: :heavy_check_mark:
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/13225 (QA-JID-940)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4741406271
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3391335853
##########
ui/public/locales/en.json:
##########
@@ -409,6 +412,11 @@
"label.api.docs.count": "APIs available for your account",
"label.api.version": "API version",
"label.apikey": "API key",
+"label.apikeypairs": "API Key Pairs",
+"label.apikeypair.description": "Description of the API key pair",
+"label.apikeypair.name": "Name of the API key pair",
+"label.apikeypair.startdate": "API key pair starting validation date",
Review Comment:
```suggestion
"label.apikeypair.startdate": "API key pair starting valid date",
```
Maybe something like this instead?
##########
ui/public/locales/pt_BR.json:
##########
@@ -379,6 +382,11 @@
"label.api.docs.count": "APIs dispon\u00edveis para sua conta",
"label.api.version": "Vers\u00e3o da API",
"label.apikey": "Chave da API",
+"label.apikeypairs": "Par de chaves de API",
+"label.apikeypair.description": "Descri\u00e7\u00e3o do par de chaves de API",
+"label.apikeypair.name": "Nome do par de chaves de API",
+"label.apikeypair.startdate": "Data de in\u00edcio de valida\u00e7\u00e3o par de chaves de API",
Review Comment:
```suggestion
"label.apikeypair.startdate": "Data de in\u00edcio da validade do par de chaves de API",
```
##########
ui/src/views/iam/ApiKeyPairPermissionTable.vue:
##########
@@ -0,0 +1,518 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <loading-outlined v-if="loadingTable" class="main-loading-spinner" />
+ <div v-else>
+ <div v-if="!disabled" class="rules-list ant-list ant-list-bordered">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab" />
+ <div class="rules-table__col rules-table__col--rule rules-table__col--new">
+ <a-auto-complete
+ :key="autocompleteKey"
+ v-focus="true"
+ :filterOption="filterOption"
+ :options="apis"
+ v-model:value="newRule"
+ :placeholder="$t('label.rule')" />
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :default-value="newRulePermission"
+ :value="newRulePermission"
+ @onChange="updateNewPermission()" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <a-input v-model:value="newRuleDescription" :placeholder="$t('label.description')" />
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ tooltipPlacement="bottom"
+ :tooltip="$t('label.save.new.rule')"
+ icon="plus-outlined"
+ type="primary"
+ @onClick="onRuleSave" />
+ </div>
+ </div>
+
+ <draggable
+ v-model="rules"
+ @change="updateRules"
+ handle=".drag-handle"
+ ghostClass="drag-ghost"
+ :component-data="{type: 'transition'}"
+ item-key="rule">
+ <template #item="{element, index}">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab drag-handle">
+ <drag-outlined />
+ </div>
+ <div class="rules-table__col rules-table__col--rule">
+ {{ element.rule }}
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :default-value="element.permission"
+ @onChange="onPermissionChange(element, $event, index)" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <div v-if="element.description">
+ {{ element.description }}
+ </div>
+ <div v-else class="no-description">
+ {{ $t('message.no.description') }}
+ </div>
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ :tooltip="$t('label.delete.rule')"
+ tooltipPlacement="bottom"
+ type="primary"
+ :danger="true"
+ icon="delete-outlined"
+ :disabled="false"
+ @onClick="onRuleDelete(element.rule, index)" />
+ </div>
+ </div>
+ </template>
+ </draggable>
+ </div>
+
+ <div :style="{width: '100%', display: 'flex', marginTop: this.rules.length > 0 ? '12px' : '0'}" v-if="this.rules.length > 0 && !disabled">
+ <a-button
+ style="width: 100%;"
+ danger
+ @click="deleteAllRules()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.delete.all.rules') }}
+ </a-button>
+ </div>
+
+ <a-table
+ v-else-if="disabled"
+ :columns="columns"
+ :dataSource="rules"
+ rowKey="rule"
+ size="large"
+ :pagination="pagination"
+ @change="handlePaginationChange">
+ <template #customFilterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }">
+ <div style="padding: 8px">
+ <a-input
+ ref="searchInput"
+ :placeholder="$t('label.search')"
+ :value="selectedKeys[0]"
+ style="width: 100%; margin-bottom: 8px; display: block"
+ @change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
+ @pressEnter="handleSearch(selectedKeys, confirm, column.dataIndex)"
+ />
+ <div style="display: flex; gap: 8px">
+ <a-button
+ type="primary"
+ size="small"
+ style="width: 112px;"
+ @click="handleSearch(selectedKeys, confirm, column.dataIndex)">
+ <template #icon>
+ <search-outlined />
+ </template>
+ {{ $t('label.search') }}
+ </a-button>
+
+ <a-button
+ size="small"
+ style="width: 112px;"
+ @click="handleReset(clearFilters)">
+ {{ $t('label.reset') }}
+ </a-button>
+ </div>
+ </div>
+ </template>
+
+ <template #customFilterIcon="{ filtered }">
+ <search-outlined :style="{ color: filtered ? '#1890ff' : '', fontSize: '14px' }" />
+ </template>
+
+ <template #bodyCell="{ column, record }">
+ <template v-if="column.key === 'permission'">
+ <a-tag
+ class="permission-tag"
+ :style="{
+ backgroundColor: record.permission === 'allow' ? '#d9f7be' : '#fff2f0',
+ color: record.permission === 'allow' ? '#135200' : '#cf1322'
+ }">
+ <check-outlined v-if="record.permission === 'allow'" />
+ <close-outlined v-else />
+ {{ record.permission === 'allow' ? $t('label.allow') : $t('label.deny') }}
+ </a-tag>
+ </template>
+
+ <template v-else-if="column.key === 'description' && record.description">
+ {{ record.description }}
+ </template>
+ </template>
+ </a-table>
+ </div>
+</template>
+
+<script>
+import { getAPI } from '@/api'
+import draggable from 'vuedraggable'
+import PermissionEditable from './PermissionEditable'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import { genericCompare } from '@/utils/sort'
+
+export default {
+ name: 'ApiKeyPairPermissionTable',
+ components: {
+ PermissionEditable,
+ draggable,
+ TooltipButton
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ loadingTable: true,
+ disabled: false,
+ rules: [],
+ newRule: '',
+ newRulePermission: 'allow',
+ newRuleDescription: '',
+ drag: false,
+ apis: [],
+ currRules: new Set(),
+ searchText: '',
+ searchedColumn: '',
+ columns: [
+ {
+ title: this.$t('label.rule'),
+ dataIndex: 'rule',
+ key: 'rule',
+ ellipsis: true,
+ customFilterDropdown: true,
+ onFilter: (value, record) => {
+ return record.rule.toString().toLowerCase().includes(value.toLowerCase())
+ },
+ sorter: (a, b) => { return genericCompare(a.rule || '', b.rule || '') },
+ width: 480
+ },
+ {
+ title: this.$t('label.permission'),
+ dataIndex: 'permission',
+ key: 'permission',
+ width: 160,
+ align: 'center',
+ sorter: (a, b) => { return genericCompare(a.permission || '', b.permission || '') }
+ },
+ {
+ title: this.$t('label.description'),
+ dataIndex: 'description',
+ key: 'description'
+ }
+ ],
+ pagination: {
+ pageSize: 20,
Review Comment:
You could use `default.ui.page.size` as a default value
##########
ui/src/views/iam/ApiKeyPairPermissionTable.vue:
##########
@@ -0,0 +1,518 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <loading-outlined v-if="loadingTable" class="main-loading-spinner" />
+ <div v-else>
+ <div v-if="!disabled" class="rules-list ant-list ant-list-bordered">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab" />
+ <div class="rules-table__col rules-table__col--rule rules-table__col--new">
+ <a-auto-complete
+ :key="autocompleteKey"
+ v-focus="true"
+ :filterOption="filterOption"
+ :options="apis"
+ v-model:value="newRule"
+ :placeholder="$t('label.rule')" />
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :default-value="newRulePermission"
+ :value="newRulePermission"
+ @onChange="updateNewPermission()" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <a-input v-model:value="newRuleDescription" :placeholder="$t('label.description')" />
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ tooltipPlacement="bottom"
+ :tooltip="$t('label.save.new.rule')"
+ icon="plus-outlined"
+ type="primary"
+ @onClick="onRuleSave" />
+ </div>
+ </div>
+
+ <draggable
+ v-model="rules"
+ @change="updateRules"
+ handle=".drag-handle"
+ ghostClass="drag-ghost"
+ :component-data="{type: 'transition'}"
+ item-key="rule">
+ <template #item="{element, index}">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab drag-handle">
+ <drag-outlined />
+ </div>
+ <div class="rules-table__col rules-table__col--rule">
+ {{ element.rule }}
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :default-value="element.permission"
+ @onChange="onPermissionChange(element, $event, index)" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <div v-if="element.description">
+ {{ element.description }}
+ </div>
+ <div v-else class="no-description">
+ {{ $t('message.no.description') }}
+ </div>
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ :tooltip="$t('label.delete.rule')"
+ tooltipPlacement="bottom"
+ type="primary"
+ :danger="true"
+ icon="delete-outlined"
+ :disabled="false"
+ @onClick="onRuleDelete(element.rule, index)" />
+ </div>
+ </div>
+ </template>
+ </draggable>
+ </div>
+
+ <div :style="{width: '100%', display: 'flex', marginTop: this.rules.length > 0 ? '12px' : '0'}" v-if="this.rules.length > 0 && !disabled">
+ <a-button
+ style="width: 100%;"
+ danger
+ @click="deleteAllRules()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.delete.all.rules') }}
+ </a-button>
+ </div>
+
+ <a-table
+ v-else-if="disabled"
+ :columns="columns"
+ :dataSource="rules"
+ rowKey="rule"
+ size="large"
+ :pagination="pagination"
+ @change="handlePaginationChange">
+ <template #customFilterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }">
+ <div style="padding: 8px">
+ <a-input
+ ref="searchInput"
+ :placeholder="$t('label.search')"
+ :value="selectedKeys[0]"
+ style="width: 100%; margin-bottom: 8px; display: block"
+ @change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
+ @pressEnter="handleSearch(selectedKeys, confirm, column.dataIndex)"
+ />
+ <div style="display: flex; gap: 8px">
+ <a-button
+ type="primary"
+ size="small"
+ style="width: 112px;"
+ @click="handleSearch(selectedKeys, confirm, column.dataIndex)">
+ <template #icon>
+ <search-outlined />
+ </template>
+ {{ $t('label.search') }}
+ </a-button>
+
+ <a-button
+ size="small"
+ style="width: 112px;"
+ @click="handleReset(clearFilters)">
+ {{ $t('label.reset') }}
+ </a-button>
+ </div>
+ </div>
+ </template>
+
+ <template #customFilterIcon="{ filtered }">
+ <search-outlined :style="{ color: filtered ? '#1890ff' : '', fontSize: '14px' }" />
+ </template>
+
+ <template #bodyCell="{ column, record }">
+ <template v-if="column.key === 'permission'">
+ <a-tag
+ class="permission-tag"
+ :style="{
+ backgroundColor: record.permission === 'allow' ? '#d9f7be' : '#fff2f0',
+ color: record.permission === 'allow' ? '#135200' : '#cf1322'
+ }">
+ <check-outlined v-if="record.permission === 'allow'" />
+ <close-outlined v-else />
+ {{ record.permission === 'allow' ? $t('label.allow') : $t('label.deny') }}
+ </a-tag>
+ </template>
+
+ <template v-else-if="column.key === 'description' && record.description">
+ {{ record.description }}
+ </template>
+ </template>
+ </a-table>
+ </div>
+</template>
+
+<script>
+import { getAPI } from '@/api'
+import draggable from 'vuedraggable'
+import PermissionEditable from './PermissionEditable'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import { genericCompare } from '@/utils/sort'
+
+export default {
+ name: 'ApiKeyPairPermissionTable',
+ components: {
+ PermissionEditable,
+ draggable,
+ TooltipButton
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ loadingTable: true,
+ disabled: false,
+ rules: [],
+ newRule: '',
+ newRulePermission: 'allow',
+ newRuleDescription: '',
+ drag: false,
+ apis: [],
+ currRules: new Set(),
+ searchText: '',
+ searchedColumn: '',
+ columns: [
+ {
+ title: this.$t('label.rule'),
+ dataIndex: 'rule',
+ key: 'rule',
+ ellipsis: true,
+ customFilterDropdown: true,
+ onFilter: (value, record) => {
+ return record.rule.toString().toLowerCase().includes(value.toLowerCase())
+ },
+ sorter: (a, b) => { return genericCompare(a.rule || '', b.rule || '') },
+ width: 480
+ },
+ {
+ title: this.$t('label.permission'),
+ dataIndex: 'permission',
+ key: 'permission',
+ width: 160,
+ align: 'center',
+ sorter: (a, b) => { return genericCompare(a.permission || '', b.permission || '') }
+ },
+ {
+ title: this.$t('label.description'),
+ dataIndex: 'description',
+ key: 'description'
+ }
+ ],
+ pagination: {
+ pageSize: 20,
+ pageSizeOptions: ['10', '20', '40', '80', '100', '200'],
+ showSizeChanger: true
+ },
+ autocompleteKey: 0
+ }
+ },
+ async created () {
+ if (this.$route.path.startsWith('/keypair')) {
+ await this.fetchKeyData()
+ this.disabled = true
+ } else {
+ this.getApis()
+ }
+ this.loadingTable = false
+ },
+ methods: {
+ handleSearch (selectedKeys, confirm, dataIndex) {
+ confirm()
+ this.searchText = selectedKeys[0]
+ this.searchedColumn = dataIndex
+ },
+ handleReset (clearFilters) {
+ clearFilters()
+ this.searchText = ''
+ },
+ handlePaginationChange (pagination) {
+ this.pagination.pageSize = pagination.pageSize
+ this.pagination.current = pagination.current
+ },
+ filterOption (input, option) {
+ return option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0
+ },
+ async fetchKeyData () {
+ try {
+ const response = await getAPI('listUserKeyRules', { keypairid: this.resource.id })
+ this.rules = response?.listuserkeyrulesresponse?.keypermission ?? []
+ } catch (e) {
+ this.$notifyError(e)
+ }
+ },
+ getApis () {
+ this.apis = Object.keys(this.$store.getters.apis).sort((a, b) => a.localeCompare(b)).map(value => { return { value: value } })
Review Comment:
It would be nice to filter only the APIs which the account receiving the keypairs has access to here
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,451 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
Review Comment:
Could you use text from the localization files here?
<img width="1268" height="616" alt="Image" src="https://github.com/user-attachments/assets/0dd8f690-2a40-4845-9360-06e205ada6c9" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4547228588
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4523395258
@winterhazel a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4734127955
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18288
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3399307508
##########
ui/public/locales/en.json:
##########
@@ -409,6 +412,11 @@
"label.api.docs.count": "APIs available for your account",
"label.api.version": "API version",
"label.apikey": "API key",
+"label.apikeypairs": "API Key Pairs",
+"label.apikeypair.description": "Description of the API key pair",
+"label.apikeypair.name": "Name of the API key pair",
+"label.apikeypair.startdate": "API key pair starting validation date",
Review Comment:
Or `API key pair valid from`. In this case, it would also make sense to adjust the end date to `API key pair valid until`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3311029380
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,456 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair
+ },
Review Comment:
`OwnershipSelection` and `Status` are imported and registered as components but never used in the template. Please drop the unused imports/components to avoid lint warnings and reduce bundle size.
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,456 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
+ ]
+ })
+ if (this.selectedRowKeys.length > 0) {
+ this.showGroupActionModal = true
+ }
+ this.deleteKeypairs(this.selectedItems)
+ },
+ async deleteKeypairs (keypairs) {
+ if (!keypairs || keypairs.length === 0) {
+ this.fetchLoading = false
+ return
+ }
+
+ this.fetchLoading = true
+ try {
+ await Promise.all(keypairs.map(async keypair => {
+ try {
+ const jobId = await this.deleteKeyPair({
+ keypairid: keypair.id
+ })
+ await this.$pollJob({
+ jobId,
+ action: {
+ isFetchData: false
+ },
+ successMethod: () => {
+ console.log('success method')
Review Comment:
Remove the leftover `console.log('success method')` from the bulk-delete poll success handler; it will spam browser devtools during normal usage.
##########
ui/public/locales/en.json:
##########
@@ -3943,6 +3963,7 @@
"message.success.create.keypair": "Successfully created SSH key pair",
"message.success.create.kubernetes.cluster": "Successfully created Kubernetes Cluster",
"message.success.create.l2.network": "Successfully created L2 Network",
+"message.success.create.password": "Successfully created API key pair for user",
Review Comment:
The `message.success.create.password` translation key added here appears unrelated to API key pairs and is not referenced anywhere in the UI. If this is meant for API key pair creation, rename it to the correct/used key (or remove it) to avoid accumulating unused i18n entries.
##########
ui/src/views/AutogenView.vue:
##########
@@ -1132,6 +1132,10 @@ export default {
params.name = this.$route.params.id
}
}
+ if (['listUserKeys'].includes(this.apiName)) {
+ delete params.listall
Review Comment:
In the `listUserKeys` special-case, `params.id` is still set earlier from the route param. `listUserKeys` does not define an `id` parameter, so this results in an “Unknown parameters: id” warning on the management server logs. Remove `params.id` here (or avoid setting it for this API) when mapping the route param to `keypairid`.
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,456 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
+ ]
+ })
Review Comment:
`eraseKeypairs()` always prepends the status column to `selectedColumns`. If the user re-runs the bulk delete in the same session, this will add duplicate status columns. Guard against re-adding the column (e.g., check whether `selectedColumns` already contains `dataIndex: 'status'` before splicing).
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/user/RegisterUserKeysCmd.java:
##########
@@ -138,6 +138,9 @@ public List<Map<String, Object>> getRules() {
String description = detail.get(ApiConstants.DESCRIPTION);
if (StringUtils.isNotEmpty(description)) {
+ if (description.length() > 255) {
+ throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Description cannot be longer than 255 characters.");
Review Comment:
This error message is ambiguous because the API also has a top-level `description` parameter for the key pair. Consider clarifying that this limit applies to the rule's description (e.g., “Rule description cannot be longer than 255 characters”).
##########
ui/src/views/iam/ApiKeyPairPermissionTable.vue:
##########
@@ -0,0 +1,520 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <loading-outlined v-if="loadingTable" class="main-loading-spinner" />
+ <div v-else>
+ <div v-if="!disabled" class="rules-list ant-list ant-list-bordered">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab" />
+ <div class="rules-table__col rules-table__col--rule rules-table__col--new">
+ <a-auto-complete
+ :key="autocompleteKey"
+ v-focus="true"
+ :filterOption="filterOption"
+ :options="apis"
+ v-model:value="newRule"
+ :placeholder="$t('label.rule')"
+ :class="{'rule-dropdown-error' : newRuleSelectError}" />
Review Comment:
`newRuleSelectError` is only used for CSS binding and is never updated anywhere, so the error styling can never activate. Either implement the error state updates (e.g., when the rule is empty/duplicate/invalid) or remove the unused state+CSS to keep the component consistent.
##########
ui/src/views/iam/GenerateApiKeyPair.vue:
##########
@@ -0,0 +1,229 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div class="form-layout" v-ctrl-enter="handleSubmit">
+ <a-modal
+ v-if="showAddKeyPair"
+ :visible="showAddKeyPair"
+ :closable="true"
+ :maskClosable="false"
+ :okText="$t('label.ok')"
+ :cancelText="$t('label.cancel')"
+ style="top: 20px;"
+ width="50vw"
+ @cancel="closeModal"
+ @ok="handleSubmit"
+ :ok-button-props="{props: { type: 'default' } }"
+ :cancel-button-props="{props: { type: 'primary' } }"
+ centered>
+ <template #title>
+ {{ $t('label.action.create.api.key') }}
+ </template>
+ <a-spin :spinning="loading">
+ <a-form
+ :ref="formRef"
+ :model="form"
+ layout="vertical"
+ @finish="handleSubmit">
+ <a-alert
+ style="margin-bottom: 10px; "
+ :message="$t('message.note.about.keypair.permissions.title')"
+ :description="$t('message.note.about.keypair.permissions.body')"
+ type="info"
+ show-icon
+ />
+ <a-form-item name="name" ref="name">
+ <template #label>
+ <tooltip-label :title="$t('label.name')" :tooltip="apiParams.name.description"/>
+ </template>
+ <a-input
+ v-focus="true"
+ :placeholder="$t('label.apikeypair.name')"
+ v-model:value="form.name" />
+ </a-form-item>
+ <a-form-item name="description" ref="description">
+ <template #label>
+ <tooltip-label :title="$t('label.description')" :tooltip="apiParams.description.description"/>
+ </template>
+ <a-input
+ v-model:value="form.description"
+ :placeholder="$t('label.apikeypair.description')" />
+ </a-form-item>
+ <a-row>
+ <a-form-item ref="startDate" name="startDate">
+ <template #label>
+ <tooltip-label :title="$t('label.start.date')" :tooltip="apiParams.startdate.description"/>
+ </template>
+ <a-date-picker
+ v-model:value="form.startDate"
+ :disabled-date="disabledStartDate"
+ show-time
+ />
+ </a-form-item>
+ <a-form-item ref="endDate" name="endDate" style="margin: 0 8px">
+ <template #label>
+ <tooltip-label :title="$t('label.end.date')" :tooltip="apiParams.enddate.description"/>
+ </template>
+ <a-date-picker
+ :disabled-date="disabledEndDate"
+ v-model:value="form.endDate"
+ show-time />
+ </a-form-item>
+ </a-row>
+ <a-form-item>
+ <template #label>
+ <tooltip-label :title="$t('label.rules')" :tooltip="apiParams.rules.description"/>
+ </template>
+ <api-key-pair-permission-table
+ :resource="resource"
+ @update-rules="updateRules"/>
+ </a-form-item>
+ </a-form>
+ </a-spin>
+ </a-modal>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, toRaw } from 'vue'
+import { postAPI } from '@/api'
+import TooltipLabel from '@/components/widgets/TooltipLabel'
+import ApiKeyPairPermissionTable from '@/views/iam/ApiKeyPairPermissionTable.vue'
+import { dayjs, parseDayJsObject } from '@/utils/date'
+
+export default {
+ name: 'GenerateApiKeyPair',
+ components: {
+ TooltipLabel,
+ ApiKeyPairPermissionTable
+ },
+ props: {
+ showAddKeyPair: {
+ type: Boolean,
+ default: false
+ },
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ rules: [],
+ loading: false
+ }
+ },
+ beforeCreate () {
+ this.apiParams = this.$getApiParams('registerUserKeys')
+ },
+ created () {
+ this.initForm()
+ },
+ methods: {
+ initForm () {
+ this.formRef = ref()
+ this.form = reactive({})
+ },
+ isValidValueForKey (obj, key) {
+ return key in obj && obj[key] != null
+ },
Review Comment:
`isValidValueForKey` is declared but never used. Please remove it (or use it) to avoid dead code in this component.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4554963180
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "bernardodemarco (via GitHub)" <gi...@apache.org>.
bernardodemarco commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4564718087
> Dear @bernardodemarco , this is excellent!
Hello, @daviftorres
Thanks!!!
> I saw in the recording that keys can be added and removed, and that the allow/deny rules are set when the key is created.
Yes, exactly. Now it is possible for a user to have multiple API key pairs, each one of them with a specific permission scope and an optional validation period during which they remain active.
During the creation of key pairs, it is optional to define their corresponding set of rule permissions. If a rule set is defined, the API key pair will only have access to APIs for which access has been explicitly granted (i.e., APIs whose corresponding rules are marked as allowed). On the other hand, if no rule set is specified, the API key pair permissions will follow and adapt to the permission set of the user's account role.
> Is it possible to later add, remove, or modify the rules for an existing key, or do you need to create a new key each time you want to change the rules?
No, it is currently not possible to update the rules of a specific key pair. The only edge-case for this is when the API key pair rule set is implicitly inferred from the user's account role (i.e., when no rules are explicitly defined for the API key pair). In these scenarios, if the user's account role permission set is changed, the corresponding key pair permissions will be adapted accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3391055611
##########
ui/public/locales/en.json:
##########
@@ -2172,6 +2186,7 @@
"label.restore.volume.attach": "Restore volume and attach",
"label.use.backup.ip.address": "Use IP Addresses from Backup",
"label.use.backup.ip.address.tooltip": "Use the same IP/MAC addresses as stored in the backup metadata. The command will error out if the IP/MAC addresses are not available",
+"label.userapikey": "API Key",
Review Comment:
`label.apikey` has the same content
##########
ui/public/locales/pt_BR.json:
##########
@@ -2462,10 +2475,13 @@
"label.usenewdiskoffering": "Substituir a oferta de disco?",
"label.user": "Usu\u00e1rio",
"label.user.conflict": "Conflito",
+"label.userapikey": "Chave de API",
+"label.usersecretkey": "Chave Secreta de API",
"label.user.data": "Dados de usu\u00e1rio",
"label.username": "Nome de usu\u00e1rio",
"label.users": "Usu\u00e1rios",
"label.usersource": "Tipo de usu\u00e1rio",
+"label.user.api.key.rules": "Regras",
Review Comment:
```suggestion
"label.user.api.key.rules": "Regras do par de chaves de API",
```
##########
ui/src/views/iam/GenerateApiKeyPair.vue:
##########
@@ -0,0 +1,226 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div class="form-layout" v-ctrl-enter="handleSubmit">
+ <a-modal
+ v-if="showAddKeyPair"
+ :visible="showAddKeyPair"
+ :closable="true"
+ :maskClosable="false"
+ :okText="$t('label.ok')"
+ :cancelText="$t('label.cancel')"
+ style="top: 20px;"
+ width="50vw"
+ @cancel="closeModal"
+ @ok="handleSubmit"
+ :ok-button-props="{props: { type: 'default' } }"
+ :cancel-button-props="{props: { type: 'primary' } }"
+ centered>
+ <template #title>
+ {{ $t('label.action.create.api.key') }}
+ </template>
+ <a-spin :spinning="loading">
+ <a-form
+ :ref="formRef"
+ :model="form"
+ layout="vertical"
+ @finish="handleSubmit">
+ <a-alert
+ style="margin-bottom: 10px; "
+ :message="$t('message.note.about.keypair.permissions.title')"
+ :description="$t('message.note.about.keypair.permissions.body')"
+ type="info"
+ show-icon
+ />
+ <a-form-item name="name" ref="name">
+ <template #label>
+ <tooltip-label :title="$t('label.name')" :tooltip="apiParams.name.description"/>
+ </template>
+ <a-input
+ v-focus="true"
+ :placeholder="$t('label.apikeypair.name')"
+ v-model:value="form.name" />
+ </a-form-item>
+ <a-form-item name="description" ref="description">
+ <template #label>
+ <tooltip-label :title="$t('label.description')" :tooltip="apiParams.description.description"/>
+ </template>
+ <a-input
+ v-model:value="form.description"
+ :placeholder="$t('label.apikeypair.description')" />
+ </a-form-item>
+ <a-row>
+ <a-form-item ref="startDate" name="startDate">
+ <template #label>
+ <tooltip-label :title="$t('label.start.date')" :tooltip="apiParams.startdate.description"/>
+ </template>
+ <a-date-picker
+ v-model:value="form.startDate"
+ :disabled-date="disabledStartDate"
+ show-time
+ />
+ </a-form-item>
+ <a-form-item ref="endDate" name="endDate" style="margin: 0 8px">
+ <template #label>
+ <tooltip-label :title="$t('label.end.date')" :tooltip="apiParams.enddate.description"/>
+ </template>
+ <a-date-picker
+ :disabled-date="disabledEndDate"
+ v-model:value="form.endDate"
+ show-time />
+ </a-form-item>
+ </a-row>
+ <a-form-item>
+ <template #label>
+ <tooltip-label :title="$t('label.rules')" :tooltip="apiParams.rules.description"/>
+ </template>
+ <api-key-pair-permission-table
+ :resource="resource"
+ @update-rules="updateRules"/>
+ </a-form-item>
+ </a-form>
+ </a-spin>
+ </a-modal>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, toRaw } from 'vue'
+import { postAPI } from '@/api'
+import TooltipLabel from '@/components/widgets/TooltipLabel'
+import ApiKeyPairPermissionTable from '@/views/iam/ApiKeyPairPermissionTable.vue'
+import { dayjs, parseDayJsObject } from '@/utils/date'
+
+export default {
+ name: 'GenerateApiKeyPair',
+ components: {
+ TooltipLabel,
+ ApiKeyPairPermissionTable
+ },
+ props: {
+ showAddKeyPair: {
+ type: Boolean,
+ default: false
+ },
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ rules: [],
+ loading: false
+ }
+ },
+ beforeCreate () {
+ this.apiParams = this.$getApiParams('registerUserKeys')
+ },
+ created () {
+ this.initForm()
+ },
+ methods: {
+ initForm () {
+ this.formRef = ref()
+ this.form = reactive({})
+ },
+ buildRequestParams () {
+ const values = toRaw(this.form)
+ this.loading = true
+ const params = {
+ name: values.name,
+ id: this.resource.id,
+ description: values.description ? values.description : null,
+ startdate: values.startDate ? parseDayJsObject({ value: values.startDate }) : null,
+ enddate: values.endDate ? parseDayJsObject({ value: values.endDate }) : null
+ }
+ for (const i in this.rules) {
+ const rule = this.rules[i]
+ params['rules[' + i + '].rule'] = rule.rule ? rule.rule : ''
+ params['rules[' + i + '].permission'] = rule.permission ? rule.permission : 'deny'
+ params['rules[' + i + '].description'] = rule.description ? rule.description : ''
+ }
+ return params
+ },
+ handleSubmit (e) {
+ if (e && typeof e.preventDefault === 'function') {
+ e.preventDefault()
+ }
+ if (this.loading) return
+ this.formRef.value.validate().then(() => {
+ const params = this.buildRequestParams()
+ this.loading = true
+ postAPI('registerUserKeys', params).then(response => {
+ this.$pollJob({
+ jobId: response.registeruserkeysresponse.jobid,
+ successMessage: `${this.$t('message.success.register.user.keypair')} ${this.$t('label.for')} user ${this.resource.id}`,
Review Comment:
You could use interpolation here to build the string instead. See `message.lock.user` for instance.
##########
ui/src/views/iam/GenerateApiKeyPair.vue:
##########
@@ -0,0 +1,226 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div class="form-layout" v-ctrl-enter="handleSubmit">
+ <a-modal
+ v-if="showAddKeyPair"
+ :visible="showAddKeyPair"
+ :closable="true"
+ :maskClosable="false"
+ :okText="$t('label.ok')"
+ :cancelText="$t('label.cancel')"
+ style="top: 20px;"
+ width="50vw"
+ @cancel="closeModal"
+ @ok="handleSubmit"
+ :ok-button-props="{props: { type: 'default' } }"
+ :cancel-button-props="{props: { type: 'primary' } }"
+ centered>
+ <template #title>
+ {{ $t('label.action.create.api.key') }}
+ </template>
+ <a-spin :spinning="loading">
+ <a-form
+ :ref="formRef"
+ :model="form"
+ layout="vertical"
+ @finish="handleSubmit">
+ <a-alert
+ style="margin-bottom: 10px; "
+ :message="$t('message.note.about.keypair.permissions.title')"
+ :description="$t('message.note.about.keypair.permissions.body')"
+ type="info"
+ show-icon
+ />
+ <a-form-item name="name" ref="name">
+ <template #label>
+ <tooltip-label :title="$t('label.name')" :tooltip="apiParams.name.description"/>
+ </template>
+ <a-input
+ v-focus="true"
+ :placeholder="$t('label.apikeypair.name')"
+ v-model:value="form.name" />
+ </a-form-item>
+ <a-form-item name="description" ref="description">
+ <template #label>
+ <tooltip-label :title="$t('label.description')" :tooltip="apiParams.description.description"/>
+ </template>
+ <a-input
+ v-model:value="form.description"
+ :placeholder="$t('label.apikeypair.description')" />
+ </a-form-item>
+ <a-row>
+ <a-form-item ref="startDate" name="startDate">
+ <template #label>
+ <tooltip-label :title="$t('label.start.date')" :tooltip="apiParams.startdate.description"/>
+ </template>
+ <a-date-picker
+ v-model:value="form.startDate"
+ :disabled-date="disabledStartDate"
+ show-time
+ />
+ </a-form-item>
+ <a-form-item ref="endDate" name="endDate" style="margin: 0 8px">
+ <template #label>
+ <tooltip-label :title="$t('label.end.date')" :tooltip="apiParams.enddate.description"/>
+ </template>
+ <a-date-picker
+ :disabled-date="disabledEndDate"
+ v-model:value="form.endDate"
+ show-time />
+ </a-form-item>
+ </a-row>
+ <a-form-item>
+ <template #label>
+ <tooltip-label :title="$t('label.rules')" :tooltip="apiParams.rules.description"/>
+ </template>
+ <api-key-pair-permission-table
+ :resource="resource"
+ @update-rules="updateRules"/>
+ </a-form-item>
+ </a-form>
+ </a-spin>
+ </a-modal>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, toRaw } from 'vue'
+import { postAPI } from '@/api'
+import TooltipLabel from '@/components/widgets/TooltipLabel'
+import ApiKeyPairPermissionTable from '@/views/iam/ApiKeyPairPermissionTable.vue'
+import { dayjs, parseDayJsObject } from '@/utils/date'
+
+export default {
+ name: 'GenerateApiKeyPair',
+ components: {
+ TooltipLabel,
+ ApiKeyPairPermissionTable
+ },
+ props: {
+ showAddKeyPair: {
+ type: Boolean,
+ default: false
+ },
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ rules: [],
+ loading: false
+ }
+ },
+ beforeCreate () {
+ this.apiParams = this.$getApiParams('registerUserKeys')
+ },
+ created () {
+ this.initForm()
+ },
+ methods: {
+ initForm () {
+ this.formRef = ref()
+ this.form = reactive({})
+ },
+ buildRequestParams () {
+ const values = toRaw(this.form)
+ this.loading = true
+ const params = {
+ name: values.name,
+ id: this.resource.id,
+ description: values.description ? values.description : null,
+ startdate: values.startDate ? parseDayJsObject({ value: values.startDate }) : null,
+ enddate: values.endDate ? parseDayJsObject({ value: values.endDate }) : null
+ }
+ for (const i in this.rules) {
+ const rule = this.rules[i]
+ params['rules[' + i + '].rule'] = rule.rule ? rule.rule : ''
+ params['rules[' + i + '].permission'] = rule.permission ? rule.permission : 'deny'
+ params['rules[' + i + '].description'] = rule.description ? rule.description : ''
+ }
+ return params
+ },
+ handleSubmit (e) {
+ if (e && typeof e.preventDefault === 'function') {
+ e.preventDefault()
+ }
+ if (this.loading) return
+ this.formRef.value.validate().then(() => {
+ const params = this.buildRequestParams()
+ this.loading = true
+ postAPI('registerUserKeys', params).then(response => {
+ this.$pollJob({
+ jobId: response.registeruserkeysresponse.jobid,
+ successMessage: `${this.$t('message.success.register.user.keypair')} ${this.$t('label.for')} user ${this.resource.id}`,
+ successMethod: () => {
+ this.fetchData()
+ },
+ errorMessage: this.$t('message.register.keypair.failed'),
+ errorMethod: () => {
+ this.fetchData()
+ },
+ loadingMessage: `${this.$t('label.registering.keypair')} ${this.$t('label.for')} user ${this.resource.id} ${this.$t('label.is.in.progress')}`,
Review Comment:
Same as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4522114057
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/13225?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 3.50%. Comparing base ([`68221cf`](https://app.codecov.io/gh/apache/cloudstack/commit/68221cf10182765c0abce1fe2e3954307335c19f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`33e91bd`](https://app.codecov.io/gh/apache/cloudstack/commit/33e91bd1d08829345939eaa4a4c041b7016f9486?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 23 commits behind head on main.
> :exclamation: There is a different number of reports uploaded between BASE (68221cf) and HEAD (33e91bd). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (68221cf) | HEAD (33e91bd) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #13225 +/- ##
=============================================
- Coverage 18.08% 3.50% -14.59%
=============================================
Files 6037 468 -5569
Lines 542609 40328 -502281
Branches 66432 7580 -58852
=============================================
- Hits 98136 1413 -96723
+ Misses 433446 38724 -394722
+ Partials 11027 191 -10836
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/13225/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/13225/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.50% <ø> (-0.02%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/13225/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/13225?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3302445732
##########
ui/src/views/iam/GenerateApiKeyPair.vue:
##########
@@ -0,0 +1,229 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div class="form-layout" v-ctrl-enter="handleSubmit">
+ <a-modal
+ v-if="showAddKeyPair"
+ :visible="showAddKeyPair"
+ :closable="true"
+ :maskClosable="false"
+ :okText="$t('label.ok')"
+ :cancelText="$t('label.cancel')"
+ style="top: 20px;"
+ width="50vw"
+ @cancel="closeModal"
+ @ok="handleSubmit"
+ :ok-button-props="{props: { type: 'default' } }"
+ :cancel-button-props="{props: { type: 'primary' } }"
+ centered>
+ <template #title>
+ {{ $t('label.action.create.api.key') }}
+ </template>
+ <a-spin :spinning="loading">
+ <a-form
+ :ref="formRef"
+ :model="form"
+ layout="vertical"
+ @finish="handleSubmit">
+ <a-alert
+ style="margin-bottom: 10px; "
+ :message="$t('message.note.about.keypair.permissions.title')"
+ :description="$t('message.note.about.keypair.permissions.body')"
+ type="info"
+ show-icon
+ />
+ <a-form-item name="name" ref="name">
+ <template #label>
+ <tooltip-label :title="$t('label.name')" :tooltip="apiParams.name.description"/>
+ </template>
+ <a-input
+ v-focus="true"
+ :placeholder="$t('label.apikeypair.name')"
+ v-model:value="form.name" />
+ </a-form-item>
+ <a-form-item name="description" ref="description">
+ <template #label>
+ <tooltip-label :title="$t('label.description')" :tooltip="apiParams.description.description"/>
+ </template>
+ <a-input
+ v-model:value="form.description"
+ :placeholder="$t('label.apikeypair.description')" />
+ </a-form-item>
+ <a-row>
+ <a-form-item ref="startDate" name="startDate">
+ <template #label>
+ <tooltip-label :title="$t('label.start.date')" :tooltip="apiParams.startdate.description"/>
+ </template>
+ <a-date-picker
+ v-model:value="form.startDate"
+ :disabled-date="disabledStartDate"
+ show-time
+ />
+ </a-form-item>
+ <a-form-item ref="endDate" name="endDate" style="margin: 0 8px">
+ <template #label>
+ <tooltip-label :title="$t('label.end.date')" :tooltip="apiParams.enddate.description"/>
+ </template>
+ <a-date-picker
+ :disabled-date="disabledEndDate"
+ v-model:value="form.endDate"
+ show-time />
+ </a-form-item>
+ </a-row>
+ <a-form-item>
+ <template #label>
+ <tooltip-label :title="$t('label.rules')" :tooltip="apiParams.rules.description"/>
+ </template>
+ <api-key-pair-permission-table
+ :resource="resource"
+ @update-rules="updateRules"/>
+ </a-form-item>
+ </a-form>
+ </a-spin>
+ </a-modal>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, toRaw } from 'vue'
+import { postAPI } from '@/api'
+import TooltipLabel from '@/components/widgets/TooltipLabel'
+import ApiKeyPairPermissionTable from '@/views/iam/ApiKeyPairPermissionTable.vue'
+import { dayjs, parseDayJsObject } from '@/utils/date'
+
+export default {
+ name: 'GenerateApiKeyPair',
+ components: {
+ TooltipLabel,
+ ApiKeyPairPermissionTable
+ },
+ props: {
+ showAddKeyPair: {
+ type: Boolean,
+ default: false
+ },
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ rules: [],
+ loading: false
+ }
+ },
+ beforeCreate () {
+ this.apiParams = this.$getApiParams('registerUserKeys')
+ },
+ created () {
+ this.initForm()
+ },
+ methods: {
+ initForm () {
+ this.formRef = ref()
+ this.form = reactive({})
+ },
+ isValidValueForKey (obj, key) {
+ return key in obj && obj[key] != null
+ },
+ buildRequestParams () {
+ const values = toRaw(this.form)
+ this.loading = true
+ const params = {
+ name: values.name,
+ id: this.resource.id,
+ description: values.description ? values.description : null,
+ startdate: values.startDate ? parseDayJsObject({ value: values.startDate }) : null,
+ endDate: values.endDate ? parseDayJsObject({ value: values.endDate }) : null
+ }
+ for (const i in this.rules) {
+ const rule = this.rules[i]
+ params['rules[' + i + '].rule'] = rule.rule ? rule.rule : ''
+ params['rules[' + i + '].permission'] = rule.permission ? rule.permission : 'deny'
+ params['rules[' + i + '].description'] = rule.description ? rule.description : ''
+ }
+ return params
+ },
+ handleSubmit (e) {
+ e.preventDefault()
Review Comment:
`handleSubmit` unconditionally calls `e.preventDefault()`, but this handler is also used for `<a-form @finish>` where Ant Design Vue passes form values (not an event). This will throw at runtime; guard for missing `preventDefault` or split modal-ok vs form-finish handlers.
##########
ui/src/views/iam/ApiKeyPairPermissionTable.vue:
##########
@@ -0,0 +1,522 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <loading-outlined v-if="loadingTable" class="main-loading-spinner" />
+ <div v-else>
+ <div v-if="!disabled" class="rules-list ant-list ant-list-bordered">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab" />
+ <div class="rules-table__col rules-table__col--rule rules-table__col--new">
+ <a-auto-complete
+ :key="autocompleteKey"
+ v-focus="true"
+ :filterOption="filterOption"
+ :options="apis"
+ v-model:value="newRule"
+ :placeholder="$t('label.rule')"
+ :class="{'rule-dropdown-error' : newRuleSelectError}" />
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :defaultValue="newRulePermission"
Review Comment:
`PermissionEditable` declares a required `defaultValue` prop, but the template passes `:defaultValue` (camelCase) which will be lowercased by HTML and not match the prop. Use kebab-case `:default-value` so the initial permission value renders correctly.
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,455 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :key="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @handle-cancel="handleCancelAddKeyPair"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+import store from '@/store'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair,
+ store
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
+ ]
+ })
+ if (this.selectedRowKeys.length > 0) {
+ this.showGroupActionModal = true
+ }
+ this.deleteKeypairs(this.selectedItems)
+ },
+ deleteKeypairs (keypairs) {
Review Comment:
When `keypairs` is empty, `deleteKeypairs` sets `fetchLoading = true` and the `forEach` body never runs, leaving the spinner stuck. Add an early return/reset when there are no items to delete.
##########
ui/public/locales/pt_BR.json:
##########
@@ -2046,6 +2058,7 @@
"label.secondarystoragelimit": "Limites do armazenamento secund\u00e1rio (GiB)",
"label.secretkey": "Chave secreta",
"label.secret.key": "Chave secreta",
+"label.apikeyaccess": "Accesso a pares de chaves de API",
Review Comment:
Typo in Portuguese translation: "Accesso" should be "Acesso".
##########
ui/src/views/iam/ApiKeyPairPermissionTable.vue:
##########
@@ -0,0 +1,522 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <loading-outlined v-if="loadingTable" class="main-loading-spinner" />
+ <div v-else>
+ <div v-if="!disabled" class="rules-list ant-list ant-list-bordered">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab" />
+ <div class="rules-table__col rules-table__col--rule rules-table__col--new">
+ <a-auto-complete
+ :key="autocompleteKey"
+ v-focus="true"
+ :filterOption="filterOption"
+ :options="apis"
+ v-model:value="newRule"
+ :placeholder="$t('label.rule')"
+ :class="{'rule-dropdown-error' : newRuleSelectError}" />
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :defaultValue="newRulePermission"
+ :value="newRulePermission"
+ @onChange="updateNewPermission()" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <a-input v-model:value="newRuleDescription" :placeholder="$t('label.description')" />
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ tooltipPlacement="bottom"
+ :tooltip="$t('label.save.new.rule')"
+ icon="plus-outlined"
+ type="primary"
+ @onClick="onRuleSave" />
+ </div>
+ </div>
+
+ <draggable
+ v-model="rules"
+ @change="updateRules"
+ handle=".drag-handle"
+ ghostClass="drag-ghost"
+ :component-data="{type: 'transition'}"
+ item-key="rule">
+ <template #item="{element, index}">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab drag-handle">
+ <drag-outlined />
+ </div>
+ <div class="rules-table__col rules-table__col--rule">
+ {{ element.rule }}
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :default-value="element.permission"
+ @onChange="onPermissionChange(element, $event, index)" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <div v-if="element.description">
+ {{ element.description }}
+ </div>
+ <div v-else class="no-description">
+ {{ $t('message.no.description') }}
+ </div>
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ :tooltip="$t('label.delete.rule')"
+ tooltipPlacement="bottom"
+ type="primary"
+ :danger="true"
+ icon="delete-outlined"
+ :disabled="false"
+ @onClick="onRuleDelete(element.rule, index)" />
+ </div>
+ </div>
+ </template>
+ </draggable>
+ </div>
+
+ <div :style="{width: '100%', display: 'flex', marginTop: this.rules.length > 0 ? '12px' : '0'}" v-if="this.rules.length > 0 && !disabled">
+ <a-button
+ style="width: 100%;"
+ danger
+ @click="deleteAllRules()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.delete.all.rules') }}
+ </a-button>
+ </div>
+
+ <a-table
+ v-else-if="disabled"
+ :columns="columns"
+ :dataSource="rules"
+ rowKey="rule"
+ size="large"
+ :pagination="pagination"
+ @change="handlePaginationChange">
+ <template #customFilterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }">
+ <div style="padding: 8px">
+ <a-input
+ ref="searchInput"
+ :placeholder="$t('label.search')"
+ :value="selectedKeys[0]"
+ style="width: 100%; margin-bottom: 8px; display: block"
+ @change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
+ @pressEnter="handleSearch(selectedKeys, confirm, column.dataIndex)"
+ />
+ <div style="display: flex; gap: 8px">
+ <a-button
+ type="primary"
+ size="small"
+ style="width: 112px;"
+ @click="handleSearch(selectedKeys, confirm, column.dataIndex)">
+ <template #icon>
+ <search-outlined />
+ </template>
+ {{ $t('label.search') }}
+ </a-button>
+
+ <a-button
+ size="small"
+ style="width: 112px;"
+ @click="handleReset(clearFilters)">
+ {{ $t('label.reset') }}
+ </a-button>
+ </div>
+ </div>
+ </template>
+
+ <template #customFilterIcon="{ filtered }">
+ <search-outlined :style="{ color: filtered ? '#1890ff' : '', fontSize: '14px' }" />
+ </template>
+
+ <template #bodyCell="{ column, record }">
+ <template v-if="column.key === 'permission'">
+ <a-tag
+ class="permission-tag"
+ :style="{
+ backgroundColor: record.permission === 'allow' ? '#d9f7be' : '#fff2f0',
+ color: record.permission === 'allow' ? '#135200' : '#cf1322'
+ }">
+ <check-outlined v-if="record.permission === 'allow'" />
+ <close-outlined v-else />
+ {{ record.permission === 'allow' ? $t('label.allow') : $t('label.deny') }}
+ </a-tag>
+ </template>
+
+ <template v-else-if="column.key === 'description' && record.description">
+ {{ record.description }}
+ </template>
+ </template>
+ </a-table>
+ </div>
+</template>
+
+<script>
+import { getAPI } from '@/api'
+import draggable from 'vuedraggable'
+import PermissionEditable from './PermissionEditable'
+import RuleDelete from './RuleDelete'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import { genericCompare } from '@/utils/sort'
+
+export default {
+ name: 'ApiKeyPairPermissionTable',
+ components: {
+ RuleDelete,
+ PermissionEditable,
+ draggable,
+ TooltipButton
Review Comment:
`RuleDelete` is imported/registered but never used in the template. This is dead code and may fail linting; remove the unused import/component registration or use it in the template.
##########
ui/src/views/iam/GenerateApiKeyPair.vue:
##########
@@ -0,0 +1,229 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div class="form-layout" v-ctrl-enter="handleSubmit">
+ <a-modal
+ v-if="showAddKeyPair"
+ :visible="showAddKeyPair"
+ :closable="true"
+ :maskClosable="false"
+ :okText="$t('label.ok')"
+ :cancelText="$t('label.cancel')"
+ style="top: 20px;"
+ width="50vw"
+ @cancel="closeModal"
+ @ok="handleSubmit"
+ :ok-button-props="{props: { type: 'default' } }"
+ :cancel-button-props="{props: { type: 'primary' } }"
+ centered>
+ <template #title>
+ {{ $t('label.action.create.api.key') }}
+ </template>
+ <a-spin :spinning="loading">
+ <a-form
+ :ref="formRef"
+ :model="form"
+ layout="vertical"
+ @finish="handleSubmit">
+ <a-alert
+ style="margin-bottom: 10px; "
+ :message="$t('message.note.about.keypair.permissions.title')"
+ :description="$t('message.note.about.keypair.permissions.body')"
+ type="info"
+ show-icon
+ />
+ <a-form-item name="name" ref="name">
+ <template #label>
+ <tooltip-label :title="$t('label.name')" :tooltip="apiParams.name.description"/>
+ </template>
+ <a-input
+ v-focus="true"
+ :placeholder="$t('label.apikeypair.name')"
+ v-model:value="form.name" />
+ </a-form-item>
+ <a-form-item name="description" ref="description">
+ <template #label>
+ <tooltip-label :title="$t('label.description')" :tooltip="apiParams.description.description"/>
+ </template>
+ <a-input
+ v-model:value="form.description"
+ :placeholder="$t('label.apikeypair.description')" />
+ </a-form-item>
+ <a-row>
+ <a-form-item ref="startDate" name="startDate">
+ <template #label>
+ <tooltip-label :title="$t('label.start.date')" :tooltip="apiParams.startdate.description"/>
+ </template>
+ <a-date-picker
+ v-model:value="form.startDate"
+ :disabled-date="disabledStartDate"
+ show-time
+ />
+ </a-form-item>
+ <a-form-item ref="endDate" name="endDate" style="margin: 0 8px">
+ <template #label>
+ <tooltip-label :title="$t('label.end.date')" :tooltip="apiParams.enddate.description"/>
+ </template>
+ <a-date-picker
+ :disabled-date="disabledEndDate"
+ v-model:value="form.endDate"
+ show-time />
+ </a-form-item>
+ </a-row>
+ <a-form-item>
+ <template #label>
+ <tooltip-label :title="$t('label.rules')" :tooltip="apiParams.rules.description"/>
+ </template>
+ <api-key-pair-permission-table
+ :resource="resource"
+ @update-rules="updateRules"/>
+ </a-form-item>
+ </a-form>
+ </a-spin>
+ </a-modal>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, toRaw } from 'vue'
+import { postAPI } from '@/api'
+import TooltipLabel from '@/components/widgets/TooltipLabel'
+import ApiKeyPairPermissionTable from '@/views/iam/ApiKeyPairPermissionTable.vue'
+import { dayjs, parseDayJsObject } from '@/utils/date'
+
+export default {
+ name: 'GenerateApiKeyPair',
+ components: {
+ TooltipLabel,
+ ApiKeyPairPermissionTable
+ },
+ props: {
+ showAddKeyPair: {
+ type: Boolean,
+ default: false
+ },
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ rules: [],
+ loading: false
+ }
+ },
+ beforeCreate () {
+ this.apiParams = this.$getApiParams('registerUserKeys')
+ },
+ created () {
+ this.initForm()
+ },
+ methods: {
+ initForm () {
+ this.formRef = ref()
+ this.form = reactive({})
+ },
+ isValidValueForKey (obj, key) {
+ return key in obj && obj[key] != null
+ },
+ buildRequestParams () {
+ const values = toRaw(this.form)
+ this.loading = true
+ const params = {
+ name: values.name,
+ id: this.resource.id,
+ description: values.description ? values.description : null,
+ startdate: values.startDate ? parseDayJsObject({ value: values.startDate }) : null,
+ endDate: values.endDate ? parseDayJsObject({ value: values.endDate }) : null
+ }
+ for (const i in this.rules) {
+ const rule = this.rules[i]
+ params['rules[' + i + '].rule'] = rule.rule ? rule.rule : ''
+ params['rules[' + i + '].permission'] = rule.permission ? rule.permission : 'deny'
+ params['rules[' + i + '].description'] = rule.description ? rule.description : ''
+ }
+ return params
+ },
+ handleSubmit (e) {
+ e.preventDefault()
+ if (this.loading) return
+ this.formRef.value.validate().then(() => {
+ const params = this.buildRequestParams()
+ this.loading = true
+ postAPI('registerUserKeys', params).then(response => {
+ this.$pollJob({
+ jobId: response.registeruserkeysresponse.jobid,
+ successMessage: `${this.$t('message.success.register.user.keypair')} ${this.$t('label.for')} user ${this.resource.id}`,
+ successMethod: () => {
+ this.fetchData()
+ },
+ errorMessage: this.$t('message.register.keypair.failed'),
+ errorMethod: () => {
+ this.fetchData()
+ },
+ loadingMessage: `${this.$t('label.registering.keypair')} ${this.$t('label.for')} user ${this.resource.id} ${this.$t('label.is.in.progress')}`,
+ catchMessage: this.$t('error.fetching.async.job.result')
+ })
+ }).catch(error => {
+ this.$notification.error({
+ message: this.$t('message.request.failed'),
+ description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message,
+ duration: 0
+ })
+ }).finally(() => {
+ this.loading = false
+ this.closeModal()
+ })
+ })
+ },
+ closeModal () {
+ this.form.name = ''
+ this.form.description = ''
+ this.form.startDate = null
+ this.form.endDate = null
Review Comment:
Closing the modal resets form fields but does not reset `rules`. Reopening the modal will keep the previous rule set and submit stale permissions; clear `this.rules` (and any related state) when closing.
##########
ui/src/views/iam/GenerateApiKeyPair.vue:
##########
@@ -0,0 +1,229 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div class="form-layout" v-ctrl-enter="handleSubmit">
+ <a-modal
+ v-if="showAddKeyPair"
+ :visible="showAddKeyPair"
+ :closable="true"
+ :maskClosable="false"
+ :okText="$t('label.ok')"
+ :cancelText="$t('label.cancel')"
+ style="top: 20px;"
+ width="50vw"
+ @cancel="closeModal"
+ @ok="handleSubmit"
+ :ok-button-props="{props: { type: 'default' } }"
+ :cancel-button-props="{props: { type: 'primary' } }"
+ centered>
+ <template #title>
+ {{ $t('label.action.create.api.key') }}
+ </template>
+ <a-spin :spinning="loading">
+ <a-form
+ :ref="formRef"
+ :model="form"
+ layout="vertical"
+ @finish="handleSubmit">
+ <a-alert
+ style="margin-bottom: 10px; "
+ :message="$t('message.note.about.keypair.permissions.title')"
+ :description="$t('message.note.about.keypair.permissions.body')"
+ type="info"
+ show-icon
+ />
+ <a-form-item name="name" ref="name">
+ <template #label>
+ <tooltip-label :title="$t('label.name')" :tooltip="apiParams.name.description"/>
+ </template>
+ <a-input
+ v-focus="true"
+ :placeholder="$t('label.apikeypair.name')"
+ v-model:value="form.name" />
+ </a-form-item>
+ <a-form-item name="description" ref="description">
+ <template #label>
+ <tooltip-label :title="$t('label.description')" :tooltip="apiParams.description.description"/>
+ </template>
+ <a-input
+ v-model:value="form.description"
+ :placeholder="$t('label.apikeypair.description')" />
+ </a-form-item>
+ <a-row>
+ <a-form-item ref="startDate" name="startDate">
+ <template #label>
+ <tooltip-label :title="$t('label.start.date')" :tooltip="apiParams.startdate.description"/>
+ </template>
+ <a-date-picker
+ v-model:value="form.startDate"
+ :disabled-date="disabledStartDate"
+ show-time
+ />
+ </a-form-item>
+ <a-form-item ref="endDate" name="endDate" style="margin: 0 8px">
+ <template #label>
+ <tooltip-label :title="$t('label.end.date')" :tooltip="apiParams.enddate.description"/>
+ </template>
+ <a-date-picker
+ :disabled-date="disabledEndDate"
+ v-model:value="form.endDate"
+ show-time />
+ </a-form-item>
+ </a-row>
+ <a-form-item>
+ <template #label>
+ <tooltip-label :title="$t('label.rules')" :tooltip="apiParams.rules.description"/>
+ </template>
+ <api-key-pair-permission-table
+ :resource="resource"
+ @update-rules="updateRules"/>
+ </a-form-item>
+ </a-form>
+ </a-spin>
+ </a-modal>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, toRaw } from 'vue'
+import { postAPI } from '@/api'
+import TooltipLabel from '@/components/widgets/TooltipLabel'
+import ApiKeyPairPermissionTable from '@/views/iam/ApiKeyPairPermissionTable.vue'
+import { dayjs, parseDayJsObject } from '@/utils/date'
+
+export default {
+ name: 'GenerateApiKeyPair',
+ components: {
+ TooltipLabel,
+ ApiKeyPairPermissionTable
+ },
+ props: {
+ showAddKeyPair: {
+ type: Boolean,
+ default: false
+ },
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ rules: [],
+ loading: false
+ }
+ },
+ beforeCreate () {
+ this.apiParams = this.$getApiParams('registerUserKeys')
+ },
+ created () {
+ this.initForm()
+ },
+ methods: {
+ initForm () {
+ this.formRef = ref()
+ this.form = reactive({})
+ },
+ isValidValueForKey (obj, key) {
+ return key in obj && obj[key] != null
+ },
+ buildRequestParams () {
+ const values = toRaw(this.form)
+ this.loading = true
+ const params = {
+ name: values.name,
+ id: this.resource.id,
+ description: values.description ? values.description : null,
+ startdate: values.startDate ? parseDayJsObject({ value: values.startDate }) : null,
+ endDate: values.endDate ? parseDayJsObject({ value: values.endDate }) : null
Review Comment:
`registerUserKeys` request params uses `endDate` instead of the API parameter name `enddate` (see `apiParams.enddate`). This will prevent the end date from being sent/recognized by the backend; rename the param key to `enddate` (keeping `form.endDate` as the UI model if desired).
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,455 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :key="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @handle-cancel="handleCancelAddKeyPair"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+import store from '@/store'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair,
+ store
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
+ ]
+ })
+ if (this.selectedRowKeys.length > 0) {
+ this.showGroupActionModal = true
+ }
+ this.deleteKeypairs(this.selectedItems)
+ },
+ deleteKeypairs (keypairs) {
+ this.fetchLoading = true
+ keypairs.forEach(async keypair => {
+ try {
+ const jobId = await this.deleteKeyPair({
+ keypairid: keypair.id
+ })
+ await this.$pollJob({
+ jobId,
+ action: {
+ isFetchData: false
+ },
+ successMethod: () => {
+ eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'success' })
+ },
+ catchMethod: () => {
+ eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
+ }
+ })
+ } catch (e) {
+ eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
+ } finally {
+ this.fetchLoading = false
+ }
+ })
Review Comment:
`deleteKeypairs` uses `forEach(async ...)` which is not awaited, and it clears `fetchLoading` inside each task; the spinner can stop early while deletions are still running. Switch to `for...of` with `await` or aggregate with `Promise.allSettled` and only clear loading once.
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,455 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :key="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @handle-cancel="handleCancelAddKeyPair"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+import store from '@/store'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair,
+ store
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
Review Comment:
`listUserKeys`'s `listall` parameter is restricted to admin roles in the backend, but this tab always sends `listall: true`. This will likely fail for normal users; only send `listall` for admin/domainadmin/resourceadmin, or omit it and rely on `userid` to scope the results.
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,455 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :key="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @handle-cancel="handleCancelAddKeyPair"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+import store from '@/store'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair,
+ store
Review Comment:
`store` is being registered under `components`, but Vue components must be component definitions (not the Vuex store instance). This will cause warnings and is unnecessary; remove `store` from the `components` object and keep using the imported `store` in methods/computed.
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,455 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :key="item => item.id"
Review Comment:
The table sets `:key="item => item.id"`, but `key` is a VNode key and should be a primitive, not a function. This can lead to unstable rendering; remove this binding (you already have `:rowKey`) or set a stable primitive key.
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/user/RegisterUserKeysCmd.java:
##########
@@ -138,6 +138,9 @@ public List<Map<String, Object>> getRules() {
String description = detail.get(ApiConstants.DESCRIPTION);
if (StringUtils.isNotEmpty(description)) {
+ if (permission.length() > 255) {
Review Comment:
Rule description length validation checks `permission.length()` instead of `description.length()`, so overlong descriptions will not be rejected and short permissions could incorrectly trigger the error. Validate the actual description string length against the DB column limit (255).
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,455 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :key="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @handle-cancel="handleCancelAddKeyPair"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+import store from '@/store'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair,
+ store
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
+ ]
+ })
+ if (this.selectedRowKeys.length > 0) {
+ this.showGroupActionModal = true
+ }
+ this.deleteKeypairs(this.selectedItems)
+ },
+ deleteKeypairs (keypairs) {
+ this.fetchLoading = true
+ keypairs.forEach(async keypair => {
+ try {
+ const jobId = await this.deleteKeyPair({
+ keypairid: keypair.id
+ })
+ await this.$pollJob({
+ jobId,
+ action: {
+ isFetchData: false
+ },
+ successMethod: () => {
+ eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'success' })
+ },
+ catchMethod: () => {
+ eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
+ }
+ })
+ } catch (e) {
+ eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
+ } finally {
+ this.fetchLoading = false
+ }
+ })
Review Comment:
`fetchLoading` is set to false in each iteration's `finally`, so with multiple selected keypairs the loading state will be incorrect (it will flip to false after the first finishes). Only clear `fetchLoading` once all deletions complete.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4560087028
<b>[SF] Trillian test result (tid-16203)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 40171 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13225-t16203-kvm-ol8.zip
Smoke tests completed. 137 look OK, 3 have errors, 11 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
ContextSuite context=TestClusterDRS>:setup | `Error` | 0.00 | test_cluster_drs.py
test_list_system_vms_metrics_history | `Failure` | 0.62 | test_metrics_api.py
test_2_userdata_on_cpvm | `Error` | 3.31 | test_systemvm_userdata.py
all_test_vnf_templates | `Skipped` | --- | test_vnf_templates.py
all_test_volumes | `Skipped` | --- | test_volumes.py
all_test_vpc_conserve_mode | `Skipped` | --- | test_vpc_conserve_mode.py
all_test_vpc_ipv6 | `Skipped` | --- | test_vpc_ipv6.py
all_test_vpc_redundant | `Skipped` | --- | test_vpc_redundant.py
all_test_vpc_router_nics | `Skipped` | --- | test_vpc_router_nics.py
all_test_vpc_vpn | `Skipped` | --- | test_vpc_vpn.py
all_test_webhook_delivery | `Skipped` | --- | test_webhook_delivery.py
all_test_webhook_lifecycle | `Skipped` | --- | test_webhook_lifecycle.py
all_test_host_maintenance | `Skipped` | --- | test_host_maintenance.py
all_test_hostha_kvm | `Skipped` | --- | test_hostha_kvm.py
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "bernardodemarco (via GitHub)" <gi...@apache.org>.
bernardodemarco commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3318581945
##########
ui/src/views/AutogenView.vue:
##########
@@ -1132,6 +1132,10 @@ export default {
params.name = this.$route.params.id
}
}
+ if (['listUserKeys'].includes(this.apiName)) {
+ delete params.listall
Review Comment:
Adding `params.id` seems to be breaking the table of API key pair rules...
##########
ui/src/views/AutogenView.vue:
##########
@@ -1132,6 +1132,10 @@ export default {
params.name = this.$route.params.id
}
}
+ if (['listUserKeys'].includes(this.apiName)) {
+ delete params.listall
Review Comment:
Adding `delete params.id` seems to be breaking the table of API key pair rules...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4660367953
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "bernardodemarco (via GitHub)" <gi...@apache.org>.
bernardodemarco commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3318581945
##########
ui/src/views/AutogenView.vue:
##########
@@ -1132,6 +1132,10 @@ export default {
params.name = this.$route.params.id
}
}
+ if (['listUserKeys'].includes(this.apiName)) {
+ delete params.listall
Review Comment:
Deleting `params.id` seems to be breaking the table of API key pair rules...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4547242467
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4547698561
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18045
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "bernardodemarco (via GitHub)" <gi...@apache.org>.
bernardodemarco commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3414666998
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,451 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
Review Comment:
Yes. For this scenario, the selected block of code manages the filters of the table's first column. I've changed it to consider the localization files:
<img width="456" height="296" alt="image" src="https://github.com/user-attachments/assets/60fe80c9-d9ea-4e23-9eb0-6a22e49faf73" />
For the first column of the table, whose value is equal to `success`, we would need to change the `BulkActionView`, I guess. But, this behavior is not exclusive for the API key pairs GUI section. I think that we could keep as it is for now and address that in the future
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4554974816
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4733776023
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4741399028
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4748069101
<b>[SF] Trillian test result (tid-16366)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52809 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13225-t16366-kvm-ol8.zip
Smoke tests completed. 151 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4523391845
@blueorangutan ui
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4660426049
@winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#issuecomment-4733770824
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "bernardodemarco (via GitHub)" <gi...@apache.org>.
bernardodemarco commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3414829466
##########
ui/src/views/iam/ApiKeyPairPermissionTable.vue:
##########
@@ -0,0 +1,518 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <loading-outlined v-if="loadingTable" class="main-loading-spinner" />
+ <div v-else>
+ <div v-if="!disabled" class="rules-list ant-list ant-list-bordered">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab" />
+ <div class="rules-table__col rules-table__col--rule rules-table__col--new">
+ <a-auto-complete
+ :key="autocompleteKey"
+ v-focus="true"
+ :filterOption="filterOption"
+ :options="apis"
+ v-model:value="newRule"
+ :placeholder="$t('label.rule')" />
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :default-value="newRulePermission"
+ :value="newRulePermission"
+ @onChange="updateNewPermission()" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <a-input v-model:value="newRuleDescription" :placeholder="$t('label.description')" />
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ tooltipPlacement="bottom"
+ :tooltip="$t('label.save.new.rule')"
+ icon="plus-outlined"
+ type="primary"
+ @onClick="onRuleSave" />
+ </div>
+ </div>
+
+ <draggable
+ v-model="rules"
+ @change="updateRules"
+ handle=".drag-handle"
+ ghostClass="drag-ghost"
+ :component-data="{type: 'transition'}"
+ item-key="rule">
+ <template #item="{element, index}">
+ <div class="rules-table-item ant-list-item">
+ <div class="rules-table__col rules-table__col--grab drag-handle">
+ <drag-outlined />
+ </div>
+ <div class="rules-table__col rules-table__col--rule">
+ {{ element.rule }}
+ </div>
+ <div class="rules-table__col rules-table__col--permission">
+ <permission-editable
+ :default-value="element.permission"
+ @onChange="onPermissionChange(element, $event, index)" />
+ </div>
+ <div class="rules-table__col rules-table__col--description">
+ <div v-if="element.description">
+ {{ element.description }}
+ </div>
+ <div v-else class="no-description">
+ {{ $t('message.no.description') }}
+ </div>
+ </div>
+ <div class="rules-table__col rules-table__col--actions">
+ <tooltip-button
+ :tooltip="$t('label.delete.rule')"
+ tooltipPlacement="bottom"
+ type="primary"
+ :danger="true"
+ icon="delete-outlined"
+ :disabled="false"
+ @onClick="onRuleDelete(element.rule, index)" />
+ </div>
+ </div>
+ </template>
+ </draggable>
+ </div>
+
+ <div :style="{width: '100%', display: 'flex', marginTop: this.rules.length > 0 ? '12px' : '0'}" v-if="this.rules.length > 0 && !disabled">
+ <a-button
+ style="width: 100%;"
+ danger
+ @click="deleteAllRules()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.delete.all.rules') }}
+ </a-button>
+ </div>
+
+ <a-table
+ v-else-if="disabled"
+ :columns="columns"
+ :dataSource="rules"
+ rowKey="rule"
+ size="large"
+ :pagination="pagination"
+ @change="handlePaginationChange">
+ <template #customFilterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }">
+ <div style="padding: 8px">
+ <a-input
+ ref="searchInput"
+ :placeholder="$t('label.search')"
+ :value="selectedKeys[0]"
+ style="width: 100%; margin-bottom: 8px; display: block"
+ @change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
+ @pressEnter="handleSearch(selectedKeys, confirm, column.dataIndex)"
+ />
+ <div style="display: flex; gap: 8px">
+ <a-button
+ type="primary"
+ size="small"
+ style="width: 112px;"
+ @click="handleSearch(selectedKeys, confirm, column.dataIndex)">
+ <template #icon>
+ <search-outlined />
+ </template>
+ {{ $t('label.search') }}
+ </a-button>
+
+ <a-button
+ size="small"
+ style="width: 112px;"
+ @click="handleReset(clearFilters)">
+ {{ $t('label.reset') }}
+ </a-button>
+ </div>
+ </div>
+ </template>
+
+ <template #customFilterIcon="{ filtered }">
+ <search-outlined :style="{ color: filtered ? '#1890ff' : '', fontSize: '14px' }" />
+ </template>
+
+ <template #bodyCell="{ column, record }">
+ <template v-if="column.key === 'permission'">
+ <a-tag
+ class="permission-tag"
+ :style="{
+ backgroundColor: record.permission === 'allow' ? '#d9f7be' : '#fff2f0',
+ color: record.permission === 'allow' ? '#135200' : '#cf1322'
+ }">
+ <check-outlined v-if="record.permission === 'allow'" />
+ <close-outlined v-else />
+ {{ record.permission === 'allow' ? $t('label.allow') : $t('label.deny') }}
+ </a-tag>
+ </template>
+
+ <template v-else-if="column.key === 'description' && record.description">
+ {{ record.description }}
+ </template>
+ </template>
+ </a-table>
+ </div>
+</template>
+
+<script>
+import { getAPI } from '@/api'
+import draggable from 'vuedraggable'
+import PermissionEditable from './PermissionEditable'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import { genericCompare } from '@/utils/sort'
+
+export default {
+ name: 'ApiKeyPairPermissionTable',
+ components: {
+ PermissionEditable,
+ draggable,
+ TooltipButton
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ }
+ },
+ data () {
+ return {
+ loadingTable: true,
+ disabled: false,
+ rules: [],
+ newRule: '',
+ newRulePermission: 'allow',
+ newRuleDescription: '',
+ drag: false,
+ apis: [],
+ currRules: new Set(),
+ searchText: '',
+ searchedColumn: '',
+ columns: [
+ {
+ title: this.$t('label.rule'),
+ dataIndex: 'rule',
+ key: 'rule',
+ ellipsis: true,
+ customFilterDropdown: true,
+ onFilter: (value, record) => {
+ return record.rule.toString().toLowerCase().includes(value.toLowerCase())
+ },
+ sorter: (a, b) => { return genericCompare(a.rule || '', b.rule || '') },
+ width: 480
+ },
+ {
+ title: this.$t('label.permission'),
+ dataIndex: 'permission',
+ key: 'permission',
+ width: 160,
+ align: 'center',
+ sorter: (a, b) => { return genericCompare(a.permission || '', b.permission || '') }
+ },
+ {
+ title: this.$t('label.description'),
+ dataIndex: 'description',
+ key: 'description'
+ }
+ ],
+ pagination: {
+ pageSize: 20,
+ pageSizeOptions: ['10', '20', '40', '80', '100', '200'],
+ showSizeChanger: true
+ },
+ autocompleteKey: 0
+ }
+ },
+ async created () {
+ if (this.$route.path.startsWith('/keypair')) {
+ await this.fetchKeyData()
+ this.disabled = true
+ } else {
+ this.getApis()
+ }
+ this.loadingTable = false
+ },
+ methods: {
+ handleSearch (selectedKeys, confirm, dataIndex) {
+ confirm()
+ this.searchText = selectedKeys[0]
+ this.searchedColumn = dataIndex
+ },
+ handleReset (clearFilters) {
+ clearFilters()
+ this.searchText = ''
+ },
+ handlePaginationChange (pagination) {
+ this.pagination.pageSize = pagination.pageSize
+ this.pagination.current = pagination.current
+ },
+ filterOption (input, option) {
+ return option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0
+ },
+ async fetchKeyData () {
+ try {
+ const response = await getAPI('listUserKeyRules', { keypairid: this.resource.id })
+ this.rules = response?.listuserkeyrulesresponse?.keypermission ?? []
+ } catch (e) {
+ this.$notifyError(e)
+ }
+ },
+ getApis () {
+ this.apis = Object.keys(this.$store.getters.apis).sort((a, b) => a.localeCompare(b)).map(value => { return { value: value } })
Review Comment:
Yes, it would. However, it is currently not possible to implement that in the GUI without changing the backend. The `listApis` API only supports the `name` attribute (i.e, it does not allow listing the APIs of a specific account) and the `listRolePermissions` API does not return implicit permissions. Thus, I believe it would not be worth it to address this in the current PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel merged PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI for API Key Pair Management [cloudstack]
Posted by "bernardodemarco (via GitHub)" <gi...@apache.org>.
bernardodemarco commented on code in PR #13225:
URL: https://github.com/apache/cloudstack/pull/13225#discussion_r3318640023
##########
ui/src/components/view/ApiKeyPairsTab.vue:
##########
@@ -0,0 +1,456 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+ <div>
+ <a-spin :spinning="fetchLoading">
+ <a-button
+ v-if="'registerUserKeys' in $store.getters.apis"
+ type="dashed"
+ style="width: 100%; margin-bottom: 15px"
+ @click="onShowAddKeyPair()">
+ <template #icon><plus-outlined /></template>
+ {{ $t('label.register.api.key') }}
+ </a-button>
+ <a-button
+ v-if="this.selectedRowKeys.length > 0 && ('deleteUserKeys' in $store.getters.apis)"
+ type="primary"
+ danger
+ style="width: 100%; margin-bottom: 15px"
+ @click="bulkActionConfirmation()">
+ <template #icon><delete-outlined /></template>
+ {{ $t('label.action.bulk.delete.api.keys') }}
+ </a-button>
+ <a-table
+ size="small"
+ style="overflow-y: auto"
+ :columns="columns"
+ :dataSource="keypairs"
+ :rowKey="item => item.id"
+ :rowSelection="rowSelection()"
+ :pagination="false" >
+ <template #name="{ record }">
+ <div>
+ <router-link :to="{ path: '/keypair/' + record.id }" >
+ {{ record.name }}
+ </router-link>
+ </div>
+ </template>
+ <template #apikey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.apikey" />
+ </strong>
+ <div>
+ {{ record.apikey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #secretkey="{ record }">
+ <strong>
+ <tooltip-button
+ tooltipPlacement="right"
+ :tooltip="$t('label.copy')"
+ icon="CopyOutlined"
+ type="dashed"
+ size="small"
+ @onClick="$message.success($t('label.copied.clipboard'))"
+ :copyResource="record.secretkey" />
+ </strong>
+ <div>
+ {{ record.secretkey.substring(0, 20) }}...
+ </div>
+ </template>
+
+ <template #startdate="{ record }">
+ <div> {{ $toLocaleDate(record.startdate) }} </div>
+ </template>
+
+ <template #enddate="{ record }">
+ <div> {{ $toLocaleDate(record.enddate)}} </div>
+ </template>
+
+ <template #created="{ record }">
+ <div> {{ $toLocaleDate(record.created) }} </div>
+ </template>
+
+ </a-table>
+ <a-divider/>
+ <a-pagination
+ class="row-element pagination"
+ size="small"
+ :current="page"
+ :pageSize="pageSize"
+ :total="totalKeypairs"
+ :showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
+ :pageSizeOptions="['10', '20', '40', '80', '100']"
+ @change="changePage"
+ @showSizeChange="changePageSize"
+ showSizeChanger>
+ <template #buildOptionText="props">
+ <span>{{ props.value }} / {{ $t('label.page') }}</span>
+ </template>
+ </a-pagination>
+ </a-spin>
+ <bulk-action-view
+ v-if="(showConfirmationAction || showGroupActionModal)"
+ :showConfirmationAction="showConfirmationAction"
+ :showGroupActionModal="showGroupActionModal"
+ :items="keypairs"
+ :selectedRowKeys="selectedRowKeys"
+ :selectedItems="selectedItems"
+ :columns="columns"
+ :selectedColumns="selectedColumns"
+ action="eraseKeypairs"
+ :loading="loading"
+ :message="bulkDeleteMessage"
+ @group-action="eraseKeypairs"
+ @handle-cancel="handleCancelBulk"
+ @close-modal="closeModalBulk" />
+ <generate-api-key-pair
+ :showAddKeyPair="showAddKeyPair"
+ :resource="resource"
+ @fetch-data="fetchData"
+ @refresh-data="handleRefreshData"
+ @close-modal="closeModalAddKeyPair" />
+ </div>
+</template>
+<script>
+import { getAPI, postAPI } from '@/api'
+import Status from '@/components/widgets/Status'
+import TooltipButton from '@/components/widgets/TooltipButton'
+import BulkActionView from '@/components/view/BulkActionView.vue'
+import eventBus from '@/config/eventBus'
+import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
+import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
+
+export default {
+ name: 'ApiKeyPairsTab',
+ components: {
+ OwnershipSelection,
+ Status,
+ TooltipButton,
+ BulkActionView,
+ GenerateApiKeyPair
+ },
+ props: {
+ resource: {
+ type: Object,
+ required: true
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ fetchLoading: false,
+ keypairs: [],
+ page: 1,
+ pageSize: 10,
+ totalKeypairs: 0,
+ selectedRowKeys: [],
+ selectedItems: [],
+ selectedColumns: [],
+ filterColumns: ['Action'],
+ showConfirmationAction: false,
+ showAddKeyPair: false,
+ showGroupActionModal: false,
+ bulkDeleteMessage: {
+ title: this.$t('label.action.bulk.delete.api.keys'),
+ confirmMessage: this.$t('label.confirm.delete.api.keys')
+ },
+ columns: [
+ {
+ title: this.$t('label.name'),
+ dataIndex: 'name',
+ slots: { customRender: 'name' }
+ },
+ {
+ title: this.$t('label.apikey'),
+ dataIndex: 'apikey',
+ slots: { customRender: 'apikey' }
+ },
+ {
+ title: this.$t('label.secretkey'),
+ dataIndex: 'secretkey',
+ slots: { customRender: 'secretkey' }
+ },
+ {
+ title: this.$t('label.start.date'),
+ dataIndex: 'startdate',
+ slots: { customRender: 'startdate' }
+ },
+ {
+ title: this.$t('label.end.date'),
+ dataIndex: 'enddate',
+ slots: { customRender: 'enddate' }
+ },
+ {
+ title: this.$t('label.created'),
+ dataIndex: 'created',
+ slots: { customRender: 'created' }
+ }
+ ]
+ }
+ },
+ created () {
+ this.fetchData()
+ },
+ watch: {
+ resource: {
+ deep: true,
+ handler (newItem) {
+ if (!newItem || !newItem.id) {
+ return
+ }
+ this.fetchData()
+ }
+ }
+ },
+ inject: ['parentFetchData'],
+ methods: {
+ fetchData () {
+ const params = {
+ listall: true,
+ page: this.page,
+ pagesize: this.pageSize,
+ userid: this.resource.id
+ }
+ this.fetchLoading = true
+ getAPI('listUserKeys', params).then(json => {
+ this.totalKeypairs = json.listuserkeysresponse.count || 0
+ this.keypairs = json.listuserkeysresponse.userapikey || []
+ }).finally(() => {
+ this.fetchLoading = false
+ })
+ },
+ setSelection (selection) {
+ this.selectedRowKeys = selection
+ this.$emit('selection-change', this.selectedRowKeys)
+ this.selectedItems = (this.keypairs.filter(function (item) {
+ return selection.indexOf(item.id) !== -1
+ }))
+ },
+ changePage (page, pageSize) {
+ this.page = page
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ changePageSize (currentPage, pageSize) {
+ this.page = currentPage
+ this.pageSize = pageSize
+ this.fetchData()
+ },
+ onShowAddKeyPair () {
+ this.showAddKeyPair = true
+ },
+ eraseKeypairs () {
+ this.selectedColumns.splice(0, 0, {
+ dataIndex: 'status',
+ title: this.$t('label.operation.status'),
+ slots: { customRender: 'status' },
+ filters: [
+ { text: 'In Progress', value: 'InProgress' },
+ { text: 'Success', value: 'success' },
+ { text: 'Failed', value: 'failed' }
+ ]
+ })
Review Comment:
These columns are only rendered after the user confirms the bulk delete operation. I was not able to reproduce duplicate status columns there...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org