Skip to content
Snippets Groups Projects
Commit 94264822 authored by igorwork's avatar igorwork
Browse files

Add method to manage authorization.

parent 21f2ab65
No related branches found
No related tags found
Loading
[[constraint]]
branch = "master"
branch = "391-device-management-ability-to-authorize-new-device"
name = "code.vereign.com/code/viam-apis"
[[constraint]]
......
......@@ -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{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment