From fb4ef0af0ff6a15df0d138afa98708bdcaa3629d Mon Sep 17 00:00:00 2001 From: igorwork <markin.io210@gmail.com> Date: Fri, 5 Apr 2019 10:58:49 +0300 Subject: [PATCH] Add function to destroy key --- handler/manage_device_key.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/handler/manage_device_key.go b/handler/manage_device_key.go index 2869e29..72a3895 100644 --- a/handler/manage_device_key.go +++ b/handler/manage_device_key.go @@ -18,8 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. package handler import ( - "log" - keyutils "code.vereign.com/code/key-storage-agent/utils" "code.vereign.com/code/viam-apis/data-storage-agent/client" "code.vereign.com/code/viam-apis/key-storage-agent/api" @@ -31,7 +29,6 @@ import ( func (s *KeyStorageServerImpl) SetAuthorized(ctx context.Context, in *api.SetAuthorizedRequest) (*api.SetAuthorizedResponse, error) { setAuthorizedResponse := &api.SetAuthorizedResponse{} - log.Printf("Auth %v", in.Value) setAuthorizedResponse.StatusList = s.updateAll(ctx, in.Uuid, func(k *api.Key) { k.Unauthorized = !in.Value }) if setAuthorizedResponse.StatusList != nil { return setAuthorizedResponse, nil @@ -40,6 +37,17 @@ func (s *KeyStorageServerImpl) SetAuthorized(ctx context.Context, in *api.SetAut return setAuthorizedResponse, nil } +func (s *KeyStorageServerImpl) Destroy(ctx context.Context, in *api.DestroyRequest) (*api.DestroyResponse, error) { + destroyResponse := &api.DestroyResponse{} + + destroyResponse.StatusList = s.updateAll(ctx, in.Uuid, func(k *api.Key) { k.Destroyed = true }) + if destroyResponse.StatusList != nil { + return destroyResponse, nil + } + destroyResponse.StatusList = utils.AddStatus(destroyResponse.StatusList, "200", api.StatusType_INFO, "Keys destroyed") + return destroyResponse, nil +} + func (s *KeyStorageServerImpl) Revoke(ctx context.Context, in *api.RevokeRequest) (*api.RevokeResponse, error) { revokeResponse := &api.RevokeResponse{} -- GitLab