util

package
v0.0.0-...-b33cfc3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJwtPart

func DecodeJwtPart(seg string) ([]byte, error)

func ExtractJwtAud

func ExtractJwtAud(jwt string) ([]string, bool)

ExtractJwtAud extracts the audiences from a JWT token. If aud cannot be parse, the bool will be set to false. This distinguishes aud=[] from not parsed.

func GetAud

func GetAud(token string) ([]string, error)

GetAud returns the claim `aud` from the token. Returns nil if not found.

func GetExp

func GetExp(token string) (time.Time, error)

GetExp returns token expiration time, or error on failures.

Types

type CertUtil

type CertUtil interface {
	// GetWaitTime returns the waiting time before renewing the certificate.
	GetWaitTime([]byte, time.Time) (time.Duration, error)
}

CertUtil is an interface for utility functions on certificate.

type CertUtilImpl

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

CertUtilImpl is the implementation of CertUtil, for production use.

func NewCertUtil

func NewCertUtil(gracePeriodPercentage int) CertUtilImpl

NewCertUtil returns a new CertUtilImpl

func (CertUtilImpl) GetWaitTime

func (cu CertUtilImpl) GetWaitTime(certBytes []byte, now time.Time) (time.Duration, error)

GetWaitTime returns the waiting time before renewing the cert, based on current time, the timestamps in cert and grace period.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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