mirror of
https://github.com/portainer/portainer.git
synced 2025-08-07 14:55:27 +02:00
fix(api-key): add password requirement to generate api key [EE-6140] (#10617)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
236e669332
commit
dbd2e609d7
20 changed files with 305 additions and 251 deletions
|
@ -5,9 +5,8 @@ import { withCurrentUser } from '@/react-tools/withCurrentUser';
|
|||
import { r2a } from '@/react-tools/react2angular';
|
||||
import { withReactQuery } from '@/react-tools/withReactQuery';
|
||||
import { withUIRouter } from '@/react-tools/withUIRouter';
|
||||
import { CreateAccessToken } from '@/react/portainer/account/CreateAccessTokenView';
|
||||
import { CreateUserAccessToken } from '@/react/portainer/account/CreateAccessTokenView';
|
||||
import { EdgeComputeSettingsView } from '@/react/portainer/settings/EdgeComputeView/EdgeComputeSettingsView';
|
||||
import { withI18nSuspense } from '@/react-tools/withI18nSuspense';
|
||||
import { EdgeAutoCreateScriptView } from '@/react/portainer/environments/EdgeAutoCreateScriptView';
|
||||
import { ListView as EnvironmentsListView } from '@/react/portainer/environments/ListView';
|
||||
import { BackupSettingsPanel } from '@/react/portainer/settings/SettingsView/BackupSettingsView/BackupSettingsPanel';
|
||||
|
@ -36,11 +35,11 @@ export const viewsModule = angular
|
|||
)
|
||||
)
|
||||
.component(
|
||||
'createAccessToken',
|
||||
r2a(withI18nSuspense(withUIRouter(CreateAccessToken)), [
|
||||
'onSubmit',
|
||||
'onError',
|
||||
])
|
||||
'createUserAccessToken',
|
||||
r2a(
|
||||
withReactQuery(withCurrentUser(withUIRouter(CreateUserAccessToken))),
|
||||
[]
|
||||
)
|
||||
)
|
||||
.component(
|
||||
'settingsEdgeCompute',
|
||||
|
|
|
@ -17,7 +17,6 @@ angular.module('portainer.app').factory('Users', [
|
|||
queryMemberships: { method: 'GET', isArray: true, params: { id: '@id', entity: 'memberships' } },
|
||||
checkAdminUser: { method: 'GET', params: { id: 'admin', entity: 'check' }, isArray: true, ignoreLoadingBar: true },
|
||||
initAdminUser: { method: 'POST', params: { id: 'admin', entity: 'init' }, ignoreLoadingBar: true },
|
||||
createAccessToken: { url: `${API_ENDPOINT_USERS}/:id/tokens`, method: 'POST', params: { id: '@id' }, ignoreLoadingBar: true },
|
||||
getAccessTokens: { method: 'GET', params: { id: '@id', entity: 'tokens' }, isArray: true },
|
||||
deleteAccessToken: { url: `${API_ENDPOINT_USERS}/:id/tokens/:tokenId`, method: 'DELETE', params: { id: '@id', entityId: '@tokenId' } },
|
||||
}
|
||||
|
|
|
@ -112,19 +112,6 @@ export function UserService($q, Users, TeamService, TeamMembershipService) {
|
|||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.createAccessToken = function (id, description) {
|
||||
const deferred = $q.defer();
|
||||
const payload = { description };
|
||||
Users.createAccessToken({ id }, payload)
|
||||
.$promise.then((data) => {
|
||||
deferred.resolve(data);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to create user', err: err });
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.getAccessTokens = function (id) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
export default class CreateUserAccessTokenController {
|
||||
/* @ngInject */
|
||||
constructor($async, $analytics, Authentication, UserService, Notifications) {
|
||||
this.$async = $async;
|
||||
this.$analytics = $analytics;
|
||||
this.Authentication = Authentication;
|
||||
this.UserService = UserService;
|
||||
this.Notifications = Notifications;
|
||||
|
||||
this.onSubmit = this.onSubmit.bind(this);
|
||||
this.onError = this.onError.bind(this);
|
||||
}
|
||||
|
||||
async onSubmit(description) {
|
||||
const accessToken = await this.UserService.createAccessToken(this.state.userId, description);
|
||||
// Dispatch analytics event upon success accessToken generation
|
||||
this.$analytics.eventTrack('portainer-account-access-token-create', { category: 'portainer' });
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
onError(heading, error, message) {
|
||||
this.Notifications.error(heading, error, message);
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
return this.$async(async () => {
|
||||
const userId = this.Authentication.getUserDetails().ID;
|
||||
this.state = {
|
||||
userId,
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<page-header title="'Create access token'" breadcrumbs="[{label:'User settings', link:'portainer.account'}, 'Add access token']" reload="true"> </page-header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<!-- mount react feature/view -->
|
||||
<create-access-token user-id="$ctrl.state.userId" on-submit="($ctrl.onSubmit)" on-success="($ctrl.onSuccess)" on-error="($ctrl.onError)"></create-access-token>
|
||||
</div>
|
||||
</div>
|
|
@ -1,7 +0,0 @@
|
|||
import angular from 'angular';
|
||||
import controller from './create-user-access-token.controller';
|
||||
|
||||
angular.module('portainer.app').component('createUserAccessToken', {
|
||||
templateUrl: './create-user-access-token.html',
|
||||
controller,
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue