43 lines
824 B
Go
43 lines
824 B
Go
|
|
package usecase
|
||
|
|
|
||
|
|
import "context"
|
||
|
|
|
||
|
|
type TokenType string
|
||
|
|
|
||
|
|
const (
|
||
|
|
TokenTypeAccess TokenType = "access"
|
||
|
|
TokenTypeRefresh TokenType = "refresh"
|
||
|
|
)
|
||
|
|
|
||
|
|
type TokenPair struct {
|
||
|
|
AccessToken string
|
||
|
|
RefreshToken string
|
||
|
|
ExpiresIn int64
|
||
|
|
TokenType string
|
||
|
|
UID string
|
||
|
|
}
|
||
|
|
|
||
|
|
type IssuePairRequest struct {
|
||
|
|
TenantID string
|
||
|
|
UID string
|
||
|
|
AuthGen int64
|
||
|
|
}
|
||
|
|
|
||
|
|
type AccessClaims struct {
|
||
|
|
TenantID string
|
||
|
|
UID string
|
||
|
|
AuthGen int64
|
||
|
|
JTI string
|
||
|
|
}
|
||
|
|
|
||
|
|
type LogoutRequest struct {
|
||
|
|
AccessToken string
|
||
|
|
}
|
||
|
|
|
||
|
|
type TokenUseCase interface {
|
||
|
|
IssuePair(ctx context.Context, req IssuePairRequest) (*TokenPair, error)
|
||
|
|
Refresh(ctx context.Context, refreshToken string) (*TokenPair, error)
|
||
|
|
Logout(ctx context.Context, req LogoutRequest) error
|
||
|
|
ParseAccessToken(ctx context.Context, accessToken string) (*AccessClaims, error)
|
||
|
|
}
|