1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 13:55:21 +02:00

feat(uac): add multi user management and UAC (#647)

This commit is contained in:
Anthony Lapenna 2017-03-12 17:24:15 +01:00 committed by GitHub
parent f28f223624
commit 80d50378c5
91 changed files with 3973 additions and 866 deletions

View file

@ -1,9 +1,11 @@
angular.module('portainer.rest')
.factory('Container', ['$resource', 'Settings', function ContainerFactory($resource, Settings) {
.factory('Container', ['$resource', 'Settings', 'EndpointProvider', function ContainerFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/containers/:id/:action', {
name: '@name'
}, {
return $resource(Settings.url + '/:endpointId/containers/:id/:action', {
name: '@name',
endpointId: EndpointProvider.endpointID
},
{
query: {method: 'GET', params: {all: 0, action: 'json', filters: '@filters' }, isArray: true},
get: {method: 'GET', params: {action: 'json'}},
stop: {method: 'POST', params: {id: '@id', t: 5, action: 'stop'}},
@ -11,7 +13,6 @@ angular.module('portainer.rest')
kill: {method: 'POST', params: {id: '@id', action: 'kill'}},
pause: {method: 'POST', params: {id: '@id', action: 'pause'}},
unpause: {method: 'POST', params: {id: '@id', action: 'unpause'}},
changes: {method: 'GET', params: {action: 'changes'}, isArray: true},
stats: {method: 'GET', params: {id: '@id', stream: false, action: 'stats'}, timeout: 5000},
start: {
method: 'POST', params: {id: '@id', action: 'start'},

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('ContainerCommit', ['$resource', 'Settings', function ContainerCommitFactory($resource, Settings) {
.factory('ContainerCommit', ['$resource', 'Settings', 'EndpointProvider', function ContainerCommitFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/commit', {}, {
return $resource(Settings.url + '/:endpointId/commit', {
endpointId: EndpointProvider.endpointID
},
{
commit: {method: 'POST', params: {container: '@id', repo: '@repo', tag: '@tag'}}
});
}]);

View file

@ -1,11 +1,11 @@
angular.module('portainer.rest')
.factory('ContainerLogs', ['$http', 'Settings', function ContainerLogsFactory($http, Settings) {
.factory('ContainerLogs', ['$http', 'Settings', 'EndpointProvider', function ContainerLogsFactory($http, Settings, EndpointProvider) {
'use strict';
return {
get: function (id, params, callback) {
$http({
method: 'GET',
url: Settings.url + '/containers/' + id + '/logs',
url: Settings.url + '/' + EndpointProvider.endpointID() + '/containers/' + id + '/logs',
params: {
'stdout': params.stdout || 0,
'stderr': params.stderr || 0,

View file

@ -1,11 +1,11 @@
angular.module('portainer.rest')
.factory('ContainerTop', ['$http', 'Settings', function ($http, Settings) {
.factory('ContainerTop', ['$http', 'Settings', 'EndpointProvider', function ($http, Settings, EndpointProvider) {
'use strict';
return {
get: function (id, params, callback, errorCallback) {
$http({
method: 'GET',
url: Settings.url + '/containers/' + id + '/top',
url: Settings.url + '/' + EndpointProvider.endpointID() + '/containers/' + id + '/top',
params: {
ps_args: params.ps_args
}

View file

@ -6,8 +6,7 @@ angular.module('portainer.rest')
query: { method: 'GET', isArray: true },
get: { method: 'GET', params: { id: '@id' } },
update: { method: 'PUT', params: { id: '@id' } },
updateAccess: { method: 'PUT', params: { id: '@id', action: 'access' } },
remove: { method: 'DELETE', params: { id: '@id'} },
getActiveEndpoint: { method: 'GET', params: { id: '0' } },
setActiveEndpoint: { method: 'POST', params: { id: '@id', action: 'active' } }
});
}]);

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('Events', ['$resource', 'Settings', function EventFactory($resource, Settings) {
.factory('Events', ['$resource', 'Settings', 'EndpointProvider', function EventFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/events', {}, {
return $resource(Settings.url + '/:endpointId/events', {
endpointId: EndpointProvider.endpointID
},
{
query: {
method: 'GET', params: {since: '@since', until: '@until'},
isArray: true, transformResponse: jsonObjectsToArrayHandler

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('Exec', ['$resource', 'Settings', function ExecFactory($resource, Settings) {
.factory('Exec', ['$resource', 'Settings', 'EndpointProvider', function ExecFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/exec/:id/:action', {}, {
return $resource(Settings.url + '/:endpointId/exec/:id/:action', {
endpointId: EndpointProvider.endpointID
},
{
resize: {
method: 'POST', params: {id: '@id', action: 'resize', h: '@height', w: '@width'},
transformResponse: genericHandler

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('Image', ['$resource', 'Settings', function ImageFactory($resource, Settings) {
.factory('Image', ['$resource', 'Settings', 'EndpointProvider', function ImageFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/images/:id/:action', {}, {
return $resource(Settings.url + '/:endpointId/images/:id/:action', {
endpointId: EndpointProvider.endpointID
},
{
query: {method: 'GET', params: {all: 0, action: 'json'}, isArray: true},
get: {method: 'GET', params: {action: 'json'}},
search: {method: 'GET', params: {action: 'search'}},

View file

@ -1,5 +1,7 @@
angular.module('portainer.rest')
.factory('Info', ['$resource', 'Settings', function InfoFactory($resource, Settings) {
.factory('Info', ['$resource', 'Settings', 'EndpointProvider', function InfoFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/info', {});
return $resource(Settings.url + '/:endpointId/info', {
endpointId: EndpointProvider.endpointID
});
}]);

View file

@ -1,7 +1,11 @@
angular.module('portainer.rest')
.factory('Network', ['$resource', 'Settings', function NetworkFactory($resource, Settings) {
.factory('Network', ['$resource', 'Settings', 'EndpointProvider', function NetworkFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/networks/:id/:action', {id: '@id'}, {
return $resource(Settings.url + '/:endpointId/networks/:id/:action', {
id: '@id',
endpointId: EndpointProvider.endpointID
},
{
query: {method: 'GET', isArray: true},
get: {method: 'GET'},
create: {method: 'POST', params: {action: 'create'}, transformResponse: genericHandler},

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('Node', ['$resource', 'Settings', function NodeFactory($resource, Settings) {
.factory('Node', ['$resource', 'Settings', 'EndpointProvider', function NodeFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/nodes/:id/:action', {}, {
return $resource(Settings.url + '/:endpointId/nodes/:id/:action', {
endpointId: EndpointProvider.endpointID
},
{
query: {method: 'GET', isArray: true},
get: {method: 'GET', params: {id: '@id'}},
update: { method: 'POST', params: {id: '@id', action: 'update', version: '@version'} },

View file

@ -0,0 +1,8 @@
angular.module('portainer.rest')
.factory('ResourceControl', ['$resource', 'USERS_ENDPOINT', function ResourceControlFactory($resource, USERS_ENDPOINT) {
'use strict';
return $resource(USERS_ENDPOINT + '/:userId/resources/:resourceType/:resourceId', {}, {
create: { method: 'POST', params: { userId: '@userId', resourceType: '@resourceType' } },
remove: { method: 'DELETE', params: { userId: '@userId', resourceId: '@resourceId', resourceType: '@resourceType' } },
});
}]);

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('Service', ['$resource', 'Settings', function ServiceFactory($resource, Settings) {
.factory('Service', ['$resource', 'Settings', 'EndpointProvider', function ServiceFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/services/:id/:action', {}, {
return $resource(Settings.url + '/:endpointId/services/:id/:action', {
endpointId: EndpointProvider.endpointID
},
{
get: { method: 'GET', params: {id: '@id'} },
query: { method: 'GET', isArray: true },
create: { method: 'POST', params: {action: 'create'} },

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('Swarm', ['$resource', 'Settings', function SwarmFactory($resource, Settings) {
.factory('Swarm', ['$resource', 'Settings', 'EndpointProvider', function SwarmFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/swarm', {}, {
return $resource(Settings.url + '/:endpointId/swarm', {
endpointId: EndpointProvider.endpointID
},
{
get: {method: 'GET'}
});
}]);

View file

@ -1,7 +1,10 @@
angular.module('portainer.rest')
.factory('Task', ['$resource', 'Settings', function TaskFactory($resource, Settings) {
.factory('Task', ['$resource', 'Settings', 'EndpointProvider', function TaskFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/tasks/:id', {}, {
return $resource(Settings.url + '/:endpointId/tasks/:id', {
endpointId: EndpointProvider.endpointID
},
{
get: { method: 'GET', params: {id: '@id'} },
query: { method: 'GET', isArray: true, params: {filters: '@filters'} }
});

View file

@ -1,12 +1,15 @@
angular.module('portainer.rest')
.factory('Users', ['$resource', 'USERS_ENDPOINT', function UsersFactory($resource, USERS_ENDPOINT) {
'use strict';
return $resource(USERS_ENDPOINT + '/:username/:action', {}, {
return $resource(USERS_ENDPOINT + '/:id/:action', {}, {
create: { method: 'POST' },
get: { method: 'GET', params: { username: '@username' } },
update: { method: 'PUT', params: { username: '@username' } },
checkPassword: { method: 'POST', params: { username: '@username', action: 'passwd' } },
checkAdminUser: { method: 'GET', params: { username: 'admin', action: 'check' } },
initAdminUser: { method: 'POST', params: { username: 'admin', action: 'init' } }
query: { method: 'GET', isArray: true },
get: { method: 'GET', params: { id: '@id' } },
update: { method: 'PUT', params: { id: '@id' } },
remove: { method: 'DELETE', params: { id: '@id'} },
// RPCs should be moved to a specific endpoint
checkPassword: { method: 'POST', params: { id: '@id', action: 'passwd' } },
checkAdminUser: { method: 'GET', params: { id: 'admin', action: 'check' }, isArray: true },
initAdminUser: { method: 'POST', params: { id: 'admin', action: 'init' } }
});
}]);

View file

@ -1,5 +1,7 @@
angular.module('portainer.rest')
.factory('Version', ['$resource', 'Settings', function VersionFactory($resource, Settings) {
.factory('Version', ['$resource', 'Settings', 'EndpointProvider', function VersionFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/version', {});
return $resource(Settings.url + '/:endpointId/version', {
endpointId: EndpointProvider.endpointID
});
}]);

View file

@ -1,7 +1,12 @@
angular.module('portainer.rest')
.factory('Volume', ['$resource', 'Settings', function VolumeFactory($resource, Settings) {
.factory('Volume', ['$resource', 'Settings', 'EndpointProvider', function VolumeFactory($resource, Settings, EndpointProvider) {
'use strict';
return $resource(Settings.url + '/volumes/:name/:action', {name: '@name'}, {
return $resource(Settings.url + '/:endpointId/volumes/:name/:action',
{
name: '@name',
endpointId: EndpointProvider.endpointID
},
{
query: {method: 'GET'},
get: {method: 'GET'},
create: {method: 'POST', params: {action: 'create'}, transformResponse: genericHandler},