mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-02 22:17:10 +08:00
43 lines
751 B
Go
43 lines
751 B
Go
![]() |
// Copyright (c) Mainflux
|
||
|
// SPDX-License-Identifier: Apache-2.0
|
||
|
|
||
|
package grpc
|
||
|
|
||
|
import "github.com/mainflux/mainflux/authn"
|
||
|
|
||
|
type identityReq struct {
|
||
|
token string
|
||
|
kind uint32
|
||
|
}
|
||
|
|
||
|
func (req identityReq) validate() error {
|
||
|
if req.token == "" {
|
||
|
return authn.ErrMalformedEntity
|
||
|
}
|
||
|
if req.kind != authn.UserKey &&
|
||
|
req.kind != authn.APIKey &&
|
||
|
req.kind != authn.RecoveryKey {
|
||
|
return authn.ErrMalformedEntity
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
type issueReq struct {
|
||
|
issuer string
|
||
|
keyType uint32
|
||
|
}
|
||
|
|
||
|
func (req issueReq) validate() error {
|
||
|
if req.issuer == "" {
|
||
|
return authn.ErrUnauthorizedAccess
|
||
|
}
|
||
|
if req.keyType != authn.UserKey &&
|
||
|
req.keyType != authn.APIKey &&
|
||
|
req.keyType != authn.RecoveryKey {
|
||
|
return authn.ErrMalformedEntity
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|