simplify token issuer/verifier interface

This commit is contained in:
David Zhao
2020-12-27 20:53:07 -08:00
parent 353f35443a
commit 46dadc25c2
13 changed files with 245 additions and 338 deletions
+9 -6
View File
@@ -2,7 +2,6 @@ package auth
import (
"errors"
"time"
)
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
@@ -11,14 +10,18 @@ var (
ErrKeysMissing = errors.New("missing API key or secret key")
)
//counterfeiter:generate . TokenIssuer
type TokenIssuer interface {
CreateToken(claims *GrantClaims, validFor time.Duration) (string, error)
}
////counterfeiter:generate . AccessToken
//type AccessToken interface {
// SetExpiration(time.Duration) AccessToken
// Identity(string) AccessToken
// AddGrant(*VideoGrant) AccessToken
// ToJWT() (string, error)
//}
//counterfeiter:generate . TokenVerifier
type TokenVerifier interface {
Verify() (*GrantClaims, error)
Identity() string
Verify(key interface{}) (*VideoGrant, error)
}
//counterfeiter:generate . KeyProvider