jwthelpers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoreTokenFactorySelector

type CoreTokenFactorySelector struct {
	JSONLoader  loaders.JSONLoader
	DataLoader  loaders.RawDataLoader
	TokenSigner TokenSigner
}

func (CoreTokenFactorySelector) Select

func (tfs CoreTokenFactorySelector) Select(tokenType int) TokenFactory

type DefaultClaims

type DefaultClaims struct {
	jwt.StandardClaims
	Username string `json:"username"`
	Role     string `json:"role"`
}

type DefaultTokenFactory

type DefaultTokenFactory struct {
	DataLoader  loaders.RawDataLoader
	TokenSigner TokenSigner
}

func (DefaultTokenFactory) CreateToken

func (tf DefaultTokenFactory) CreateToken(keyUri string, clientUID uuid.UUID, username string, role string) (string, error)

type FirebaseClaims

type FirebaseClaims struct {
	jwt.StandardClaims
	Algorithm string            `json:"alg"`
	UID       string            `json:"uid"`
	Claims    map[string]string `json:"claims"`
}

type FirebaseServiceJSON

type FirebaseServiceJSON struct {
	ClientEmail string `json:"client_email"`
	PrivateKey  string `json:"private_key"`
}

type FirebaseTokenFactory

type FirebaseTokenFactory struct {
	JSONLoader  loaders.JSONLoader
	TokenSigner TokenSigner
}

func (FirebaseTokenFactory) CreateToken

func (tf FirebaseTokenFactory) CreateToken(keyUri string, _ uuid.UUID, username string, role string) (string, error)

type JWTTokenSigner

type JWTTokenSigner struct{}

func (JWTTokenSigner) SignToken

func (JWTTokenSigner) SignToken(token *jwt.Token, key []byte) (string, error)

type TokenFactory

type TokenFactory interface {
	// CreateToken creates a signed JWT using the key loaded from the key uri.
	// Should also include the username and role in its claims and optionally the client uid.
	// Returns the token string any errors.
	CreateToken(keyUri string, clientUID uuid.UUID, username string, role string) (string, error)
}

type TokenFactorySelector

type TokenFactorySelector interface {
	// Select selects the TokenFactory based on the provided tokenType.
	// Returns the TokenFactory, or nil if the type is unknown.
	Select(tokenType int) TokenFactory
}

type TokenSigner

type TokenSigner interface {
	// SignToken signs the token using the private key.
	// Returns the signed token string and any errors.
	SignToken(token *jwt.Token, key []byte) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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