auth

package
v0.0.0-...-277766b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTManager

type JWTManager struct {
	Store        models.UserStore
	Audience     string
	TokenExpires time.Duration
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL