Documentation ¶
Index ¶
- Variables
- type Challenger
- type Options
- type Service
- func (s *Service) DestroySession(ctx context.Context, old *Session) error
- func (s *Service) IsValidJWT(tokenStr string) (bool, error)
- func (s *Service) IsValidRefresh(ctx context.Context, userId, refresh string) (bool, error)
- func (s *Service) Renew(ctx context.Context, old *Session) (*Session, error)
- func (s *Service) SessionWithChallenge(ctx context.Context, userId, password string) (*Session, error)
- type Session
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCipherTooShort = errors.New("cipher is too short") ErrMessAuthFailed = errors.New("cipher: message authentication failed") )
Functions ¶
This section is empty.
Types ¶
type Challenger ¶
type Challenger struct {
// contains filtered or unexported fields
}
Challenger holds methods to create and validate user challenges
func NewChallenger ¶
func NewChallenger(saltLen int, keys [][]byte) *Challenger
NewChallenger will initialise a new Challenger
type Options ¶
type Options struct { // Token Length for a refresh token RefreshTokenLength int // JWT Expiration time JWTokenExpiration time.Duration // Refresh Expiration time RefreshTokenExpiration time.Duration // length of password salts SaltLength int }
Options for tokens
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an authentication service used for manipulating sessions
func NewService ¶
func NewService(secret string, repo repository.DepositWithdrawer, keys []string, opt *Options) *Service
NewService will create a new auth service
func (*Service) DestroySession ¶
DestroySession will invalidate a session by blacklisting the jwt and removing the refresh token from the users record
func (*Service) IsValidJWT ¶
IsValidJWT will attempt to parse the jwt and check if it has expired. If it fails to parse or has expired then the jwt is invalid
func (*Service) IsValidRefresh ¶
IsValidRefresh will query the repository and validate that it exists, if it doesn't then the token is invalid
Click to show internal directories.
Click to hide internal directories.