2020-05-18 12:06:36 +02:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2024-04-03 13:43:43 +03:00
|
|
|
"time"
|
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2023-12-08 16:30:55 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2020-05-18 12:06:36 +02:00
|
|
|
)
|
|
|
|
|
2020-10-15 13:52:41 +02:00
|
|
|
type TokenView struct {
|
2020-08-28 09:44:43 +02:00
|
|
|
ID string
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
ResourceOwner string
|
|
|
|
UserID string
|
|
|
|
ApplicationID string
|
|
|
|
UserAgentID string
|
|
|
|
Audience []string
|
|
|
|
Expiration time.Time
|
|
|
|
Scopes []string
|
|
|
|
Sequence uint64
|
|
|
|
PreferredLanguage string
|
2021-11-03 08:35:24 +01:00
|
|
|
RefreshTokenID string
|
2022-02-08 09:37:28 +01:00
|
|
|
IsPAT bool
|
2024-03-20 12:18:46 +02:00
|
|
|
Reason domain.TokenReason
|
|
|
|
Actor *domain.TokenActor
|
2020-05-18 12:06:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type TokenSearchRequest struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
SortingColumn TokenSearchKey
|
|
|
|
Asc bool
|
|
|
|
Queries []*TokenSearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
type TokenSearchKey int32
|
|
|
|
|
|
|
|
const (
|
2020-06-23 14:47:47 +02:00
|
|
|
TokenSearchKeyUnspecified TokenSearchKey = iota
|
|
|
|
TokenSearchKeyTokenID
|
|
|
|
TokenSearchKeyUserID
|
2021-11-03 08:35:24 +01:00
|
|
|
TokenSearchKeyRefreshTokenID
|
2020-06-23 14:47:47 +02:00
|
|
|
TokenSearchKeyApplicationID
|
|
|
|
TokenSearchKeyUserAgentID
|
|
|
|
TokenSearchKeyExpiration
|
|
|
|
TokenSearchKeyResourceOwner
|
2022-03-23 09:02:39 +01:00
|
|
|
TokenSearchKeyInstanceID
|
2020-05-18 12:06:36 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type TokenSearchQuery struct {
|
|
|
|
Key TokenSearchKey
|
2021-03-01 08:48:50 +01:00
|
|
|
Method domain.SearchMethod
|
2020-10-16 07:49:38 +02:00
|
|
|
Value interface{}
|
2020-05-18 12:06:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type TokenSearchResponse struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
TotalResult uint64
|
|
|
|
Result []*Token
|
|
|
|
}
|
|
|
|
|
2021-04-06 16:03:07 +02:00
|
|
|
func (r *TokenSearchRequest) EnsureLimit(limit uint64) error {
|
|
|
|
if r.Limit > limit {
|
2023-12-08 16:30:55 +02:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "SEARCH-M0fse", "Errors.Limit.ExceedsDefault")
|
2021-04-06 16:03:07 +02:00
|
|
|
}
|
|
|
|
if r.Limit == 0 {
|
2020-05-18 12:06:36 +02:00
|
|
|
r.Limit = limit
|
|
|
|
}
|
2021-04-06 16:03:07 +02:00
|
|
|
return nil
|
2020-05-18 12:06:36 +02:00
|
|
|
}
|