initial commit
This commit is contained in:
37
pkg/jwt/jwt.go
Normal file
37
pkg/jwt/jwt.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user