Documentation ¶
Overview ¶
thanks to @elithrar for the code to create the secret token! source: https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func ValidateToken ¶
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(authStorage storage.UserInteractor, key []byte) *Authenticator
func (*Authenticator) AuthenticateToken ¶
func (auth *Authenticator) AuthenticateToken(authToken, refreshToken, csrfToken string, key []byte) (model.Token, error)
AuthenticateToken check token and return new token
func (*Authenticator) CreateNewToken ¶
CreateNewToken generate new token with JWT using HS256 method return token and error
func (*Authenticator) RevokeRefreshToken ¶
func (auth *Authenticator) RevokeRefreshToken(refreshToken string) error
RevokeRefreshToken remove refresh token from storage