38 lines
718 B
Go
38 lines
718 B
Go
package jwt
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type AccessRefreshTokenPair struct {
|
|
AccessToken string
|
|
AccessTokenExpiresAt time.Time
|
|
RefreshToken string
|
|
RefreshTokenExpiresAt time.Time
|
|
}
|
|
|
|
type TokenPayload struct {
|
|
Sub string
|
|
Aud []string
|
|
Iat time.Time
|
|
Exp time.Time
|
|
Iss string
|
|
}
|
|
|
|
type GenerateTokenInput struct {
|
|
Sub string
|
|
Aud string
|
|
Exp time.Time
|
|
}
|
|
|
|
type TokenData struct {
|
|
Sub string
|
|
}
|
|
|
|
type TokenService interface {
|
|
GenerateAccessRefreshTokenPair(ctx context.Context, tokenData *TokenData) (*AccessRefreshTokenPair, error)
|
|
VerifyToken(ctx context.Context, accessToken string) (*TokenPayload, error)
|
|
GenerateToken(ctx context.Context, input *GenerateTokenInput) (string, error)
|
|
}
|