diff --git a/Gopkg.toml b/Gopkg.toml index 56fd4154d480097761aefd7c8bfe6a1b7fa872d3..bb3dd739e1413aff74b9aecc5d1374283b170898 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,5 +1,5 @@ [[constraint]] - branch = "master" + branch = "391-device-management-ability-to-authorize-new-device" name = "code.vereign.com/code/viam-apis" [[constraint]] diff --git a/handler/revoke.go b/handler/revoke.go index 5f02f9b87c5a5efbbc5127e667815298feb1b655..2869e293df34ac38453b6e642f7bf4bcac0cd64c 100644 --- a/handler/revoke.go +++ b/handler/revoke.go @@ -18,6 +18,8 @@ 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" @@ -26,6 +28,18 @@ import ( "golang.org/x/net/context" ) +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 + } + setAuthorizedResponse.StatusList = utils.AddStatus(setAuthorizedResponse.StatusList, "200", api.StatusType_INFO, "Keys authorization updated") + return setAuthorizedResponse, nil +} + func (s *KeyStorageServerImpl) Revoke(ctx context.Context, in *api.RevokeRequest) (*api.RevokeResponse, error) { revokeResponse := &api.RevokeResponse{}