jwt

package
v0.0.0-...-88dbfc4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

README

jwt

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContextKeyUser = contextKey("user")
	ContextGitId   = contextKey("gitid")
)

Functions

func CreateGitCollabJwt

func CreateGitCollabJwt(username string, gitID int64, secret string) (string, error)

Create a new JWT for the frontend (NOT GITHUB). All requests from the frontend will contain this JWT, if modified or expired, will return error to frontend

func GetExpTime

func GetExpTime(tokenString string) (time.Time, error)

Get the time a given JWT expires at. Takes the jwt string and returns time it expires at as time.Time

func GetJwtFromHeader

func GetJwtFromHeader(r *http.Request) string

Retrieve JWT from the header, return empty string if no JWT

func InsertJwtBlacklist

func InsertJwtBlacklist(pg *db.PostgresDriver, jwtString string) error

Insert a JWT to the blacklist table. Any requests with a header containing this JWT will return an error to the frontend

func JWTBlackList

func JWTBlackList(db *db.PostgresDriver) func(http.Handler) http.Handler

Middleware to check if a given JWT is blacklisted All private routes with JWT headers should pass through this middleware

Types

type GitCollabJwtConf

type GitCollabJwtConf struct {
	// contains filtered or unexported fields
}

func NewGitCollabJwtConf

func NewGitCollabJwtConf(secret string) *GitCollabJwtConf

func (*GitCollabJwtConf) VerifyJWT

func (g *GitCollabJwtConf) VerifyJWT(logger *logrus.Logger) func(http.Handler) http.Handler

Jump to

Keyboard shortcuts

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