github.com/annwntech/go-micro/v2@v2.9.5/auth/token/token.go (about)

     1  package token
     2  
     3  import (
     4  	"errors"
     5  	"time"
     6  
     7  	"github.com/annwntech/go-micro/v2/auth"
     8  )
     9  
    10  var (
    11  	// ErrNotFound is returned when a token cannot be found
    12  	ErrNotFound = errors.New("token not found")
    13  	// ErrEncodingToken is returned when the service encounters an error during encoding
    14  	ErrEncodingToken = errors.New("error encoding the token")
    15  	// ErrInvalidToken is returned when the token provided is not valid
    16  	ErrInvalidToken = errors.New("invalid token provided")
    17  )
    18  
    19  // Provider generates and inspects tokens
    20  type Provider interface {
    21  	Generate(account *auth.Account, opts ...GenerateOption) (*Token, error)
    22  	Inspect(token string) (*auth.Account, error)
    23  	String() string
    24  }
    25  
    26  type Token struct {
    27  	// The actual token
    28  	Token string `json:"token"`
    29  	// Time of token creation
    30  	Created time.Time `json:"created"`
    31  	// Time of token expiry
    32  	Expiry time.Time `json:"expiry"`
    33  }