jwt_handler

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JWTAlgorithm       = "RS256"
	MaxExpirationDelta = 60 * 60 * 24 * 7 // 7 days in seconds
	MinExpirationDelta = 60 * 60          // 1 hour in seconds
)

Variables

This section is empty.

Functions

func CreateClaims

func CreateClaims(j *JWTHandler) jwt.Claims

func ParseRSAPrivateKeyFromPEM

func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)

func ParseRSAPublicKeyFromPrivateKeyPEM

func ParseRSAPublicKeyFromPrivateKeyPEM(key []byte) (*rsa.PublicKey, error)

Types

type JWTHandler

type JWTHandler struct {
	ServiceAccount      *service_account.ServiceAccount
	Audience            string
	ExpirationTime      time.Duration
	SecondsBeforeExpire time.Duration
}

func NewJWTHandler

func NewJWTHandler(sa *service_account.ServiceAccount, secondsBeforeExpire, tokenDuration int, audience string) (*JWTHandler, error)

func (*JWTHandler) GenerateToken

func (j *JWTHandler) GenerateToken() (string, error)

func (*JWTHandler) IsTokenExpired

func (j *JWTHandler) IsTokenExpired(tokenString string) (bool, error)

Jump to

Keyboard shortcuts

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