mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-29 13:49:28 +08:00

* Change CanAccess to CanAccessByKey for things Signed-off-by: Nick Neisen <nwneisen@gmail.com> * Change CanAccess in remaining occurances Signed-off-by: Nick Neisen <nwneisen@gmail.com> * Regenerate generated files Signed-off-by: Nick Neisen <nwneisen@gmail.com> * Generate pb.go files with protoc 3.6.1 Signed-off-by: Nick Neisen <nwneisen@gmail.com>
51 lines
844 B
Go
51 lines
844 B
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package http
|
|
|
|
import "github.com/mainflux/mainflux/things"
|
|
|
|
var _ apiReq = (*identifyReq)(nil)
|
|
|
|
type apiReq interface {
|
|
validate() error
|
|
}
|
|
|
|
type identifyReq struct {
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
func (req identifyReq) validate() error {
|
|
if req.Token == "" {
|
|
return things.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type canAccessByKeyReq struct {
|
|
chanID string
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
func (req canAccessByKeyReq) validate() error {
|
|
if req.Token == "" || req.chanID == "" {
|
|
return things.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type canAccessByIDReq struct {
|
|
chanID string
|
|
ThingID string `json:"thing_id"`
|
|
}
|
|
|
|
func (req canAccessByIDReq) validate() error {
|
|
if req.ThingID == "" || req.chanID == "" {
|
|
return things.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|