mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-26 13:26:41 +08:00
Save sharing keys to db
This commit is contained in:
parent
fd80367808
commit
2d19e38e8a
6 changed files with 46 additions and 9 deletions
|
|
@ -27,6 +27,7 @@ return [
|
|||
['name' => 'vault#get', 'url' => '/api/v2/vaults/{vault_id}', 'verb' => 'GET'],
|
||||
['name' => 'vault#update', 'url' => '/api/v2/vaults/{vault_id}', 'verb' => 'PATCH'],
|
||||
['name' => 'vault#delete', 'url' => '/api/v2/vaults/{vault_id}', 'verb' => 'DELETE'],
|
||||
['name' => 'vault#updateSharingKeys', 'url' => '/api/v2/vaults/{vault_id}/sharing-keys', 'verb' => 'POST'],
|
||||
|
||||
//Credential
|
||||
['name' => 'credential#createCredential', 'url' => '/api/v2/credentials', 'verb' => 'POST'],
|
||||
|
|
|
|||
|
|
@ -67,6 +67,14 @@ class VaultController extends ApiController {
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function updateSharingKeys($vault_id, $private_sharing_key, $public_sharing_key) {
|
||||
$this->vaultService->updateSharingKeys($vault_id, $private_sharing_key, $public_sharing_key);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,13 +2,18 @@
|
|||
* Created by wolfi on 25/09/16.
|
||||
*/
|
||||
angular.module('passmanApp')
|
||||
.controller('SharingSettingsCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService) {
|
||||
$scope.active_vault = VaultService.getActiveVault();
|
||||
.controller('SharingSettingsCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService',
|
||||
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService) {
|
||||
$scope.active_vault = VaultService.getActiveVault();
|
||||
|
||||
$scope.generateKeys = function(length) {
|
||||
var rsa = ShareService.rsaKeyPairToPEM(ShareService.generateRSAKeys(length));
|
||||
console.log(rsa);
|
||||
$scope.active_vault.private_sharing_key = rsa.privateKey;
|
||||
$scope.active_vault.public_sharing_key = rsa.publicKey;
|
||||
}
|
||||
}]);
|
||||
$scope.generateKeys = function (length) {
|
||||
var rsa = ShareService.rsaKeyPairToPEM(ShareService.generateRSAKeys(length));
|
||||
console.log(rsa);
|
||||
$scope.active_vault.private_sharing_key = rsa.privateKey;
|
||||
$scope.active_vault.public_sharing_key = rsa.publicKey;
|
||||
VaultService.updateSharingKeys($scope.active_vault).then(function (result) {
|
||||
console.log('done')
|
||||
})
|
||||
|
||||
}
|
||||
}]);
|
||||
|
|
@ -58,6 +58,16 @@ angular.module('passmanApp')
|
|||
}
|
||||
});
|
||||
},
|
||||
updateSharingKeys: function (vault) {
|
||||
var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + vault.vault_id +'/sharing-keys');
|
||||
return $http.post(queryUrl, vault).then(function (response) {
|
||||
if(response.data){
|
||||
return response.data;
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteVault: function (vault) {
|
||||
var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + vault.vault_id);
|
||||
return $http.delete(queryUrl).then(function (response) {
|
||||
|
|
|
|||
|
|
@ -55,4 +55,13 @@ class VaultMapper extends Mapper {
|
|||
$vault->setlastAccess(time());
|
||||
$this->update($vault);
|
||||
}
|
||||
|
||||
public function updateSharingKeys($vault_id, $privateKey, $publicKey){
|
||||
$vault = new Vault();
|
||||
$vault->setId($vault_id);
|
||||
$vault->setPrivateSharingKey($privateKey);
|
||||
$vault->setPublicSharingKey($publicKey);
|
||||
$vault->setSharingKeysGenerated($this->utils->getTime());
|
||||
$this->update($vault);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,4 +36,8 @@ class VaultService {
|
|||
public function setLastAccess($vault_id){
|
||||
return $this->vaultMapper->setLastAccess($vault_id);
|
||||
}
|
||||
|
||||
public function updateSharingKeys($vault_id, $privateKey, $publicKey){
|
||||
return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue