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