Files
magistrala/auth/api/grpc/token/requests.go
T
Dušan Borovčanin 61d0427898 NOISSUE - Rename to Magistrala (#3427)
Signed-off-by: dusan <borovcanindusan1@gmail.com>
2026-04-06 15:23:42 +02:00

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
}