Documentation ¶
Index ¶
- Variables
- func NewEmailTokenString(issuer, login, email, passwordHash string, expiration time.Duration, ...) (string, error)
- func NewStateTokenString(issuer, providerID string, expiration time.Duration, signKey []byte) (string, error)
- func NewStateWithLoginTokenString(issuer, providerID, login string, expiration time.Duration, signKey []byte) (string, error)
- type EmailToken
- type StateToken
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidToken = errors.New("invalid token")
ErrInvalidToken error returned when token cannot be parsed.
Functions ¶
func NewEmailTokenString ¶
func NewEmailTokenString( issuer, login, email, passwordHash string, expiration time.Duration, signKey []byte) (string, error)
NewEmailTokenString creates new jwt token and converts it to signed string. It may be used to create password reset URL for confirmation email.
func NewStateTokenString ¶
func NewStateTokenString( issuer, providerID string, expiration time.Duration, signKey []byte) (string, error)
NewStateTokenString creates new jwt token and converts it to signed string. It can be used to create state token for OAuth2 code flow.
func NewStateWithLoginTokenString ¶
func NewStateWithLoginTokenString( issuer, providerID, login string, expiration time.Duration, signKey []byte) (string, error)
NewStateWithLoginTokenString creates new jwt token and converts it to signed string. It can be used to create state token for OAuth2 code flow. This method additionally packs login into token, which is useful in case of login/password authentication via application's own login form.
Types ¶
type EmailToken ¶
type EmailToken interface { // Login returns user's login. Login() string // Email returns users's email which token was issued for. Email() string // PasswordHash returns the hash of the password. // Password hash goes into the token and then into the link, which is // included into the email for the user. When the user follow the link, // the token is returned to the server in the url param and the hash is // used to check if the password has not been changed yet. PasswordHash() string }
EmailToken represents token, used to be sent in confirmation email.
func ParseEmailToken ¶
func ParseEmailToken( issuer, token string, signKey []byte) (EmailToken, error)
ParseEmailToken can parse jwt tokens from strings created by NewEmailTokenString.
type StateToken ¶
type StateToken interface { // ProviderID is an ID of OAuth2 provider, used to initiate auth request. ProviderID() string // User's login if known at state creation (like in case of form-based auth) Login() string }
StateToken represents state token.
func ParseStateToken ¶
func ParseStateToken( issuer, token string, signKey []byte) (StateToken, error)
ParseStateToken can parse jwt tokens from strings created by NewStateTokenString or NewStateWithLoginTokenString.