Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JWTManager ¶
func (*JWTManager) CreateForUser ¶
func (m *JWTManager) CreateForUser(u *models.User) (string, *models.SessionKey, error)
CreateForUser creates a new JWT based on the passed user. In some cases it may also need to generate a new SessionKey for the purpose of encrypting those JWTs. Callers should be sure to save the returned SessionKey, if there is one, to the user when setting the token otherwise the token signature will not be able to be validated on subsequent requests.
func (*JWTManager) Validate ¶
func (m *JWTManager) Validate(j string) (*models.User, error)
Validate performs validate of a JWT for authentication. If the authentication was successful it will return the user model for the authenticated user.
JWTs are signed by a per-user key on the service side. These keys may be generated automatically when issuing a token to the user or, in the case of service accounts, they may be generated by the user and validated on the service side with the user's public key.