mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
61d0427898
Signed-off-by: dusan <borovcanindusan1@gmail.com>
67 lines
1.1 KiB
Go
67 lines
1.1 KiB
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package token
|
|
|
|
import (
|
|
apiutil "github.com/absmach/magistrala/api/http/util"
|
|
"github.com/absmach/magistrala/auth"
|
|
)
|
|
|
|
type issueReq struct {
|
|
userID string
|
|
userRole auth.Role
|
|
keyType auth.KeyType
|
|
verified bool
|
|
description string
|
|
}
|
|
|
|
func (req issueReq) validate() error {
|
|
if req.keyType != auth.AccessKey &&
|
|
req.keyType != auth.APIKey &&
|
|
req.keyType != auth.RecoveryKey &&
|
|
req.keyType != auth.InvitationKey {
|
|
return apiutil.ErrInvalidAuthKey
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type refreshReq struct {
|
|
refreshToken string
|
|
verified bool
|
|
}
|
|
|
|
func (req refreshReq) validate() error {
|
|
if req.refreshToken == "" {
|
|
return apiutil.ErrMissingSecret
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type revokeReq struct {
|
|
userID string
|
|
tokenID string
|
|
}
|
|
|
|
func (req revokeReq) validate() error {
|
|
if req.tokenID == "" {
|
|
return apiutil.ErrMissingID
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type listUserRefreshTokensReq struct {
|
|
userID string
|
|
}
|
|
|
|
func (req listUserRefreshTokensReq) validate() error {
|
|
if req.userID == "" {
|
|
return apiutil.ErrMissingID
|
|
}
|
|
|
|
return nil
|
|
}
|