jwtutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package jwtutil simplifies generating properly formatted web tokens for our use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTestKeys

func LoadTestKeys(t *testing.T) jwk.Set

LoadTestKeys is a helper method to load test keys, which obviously should not be used in production...

func MakeAgentJWT

func MakeAgentJWT(agent string, clock jwt.Clock) (string, error)

MakeAgentJWT will return a token with provided type, name, and agent name embedded in the claims.

func MakeServiceJWT

func MakeServiceJWT(epType string, epName string, agent string, clock jwt.Clock) (string, error)

MakeServiceJWT will return a token with provided type, name, and agent name embedded in the claims.

func MutateHeader

func MutateHeader(data string, clock jwt.Clock) (signed []byte, err error)

MutateHeader will take a header value (as a string) and return a JWT which we can later use in UnmutateHeader to recover the original string value.

func MutationIsRegistered

func MutationIsRegistered() bool

MutationIsRegistered indicates if RegisterMutationKeyset was called at least once.

func RegisterAgentKeyset

func RegisterAgentKeyset(keyset jwk.Set, signingKeyName string) error

RegisterAgentKeyset registers (or re-registers) a new keyset and signing key name.

func RegisterMutationKeyset

func RegisterMutationKeyset(keyset jwk.Set, signingKeyName string) error

RegisterMutationKeyset registers (or re-registers) a new keyset and signing key name.

func RegisterServiceKeyset

func RegisterServiceKeyset(keyset jwk.Set, signingKeyName string) error

RegisterServiceKeyset registers (or re-registers) a new keyset and signing key name.

func UnmutateHeader

func UnmutateHeader(tokenString []byte, clock jwt.Clock) (username string, err error)

UnmutateHeader checks the mutated data and returns the unmutated original content.

func UnregisterMutationKeyset

func UnregisterMutationKeyset()

UnregisterMutationKeyset removes the registration. This is mostly for testing.

func ValidateAgentJWT

func ValidateAgentJWT(tokenString string, clock jwt.Clock) (string, error)

ValidateAgentJWT will validate and return the enbedded claims.

func ValidateServiceJWT

func ValidateServiceJWT(tokenString string, clock jwt.Clock) (epType string, epName string, agent string, err error)

ValidateServiceJWT will validate and return the enbedded claims.

Types

This section is empty.

Jump to

Keyboard shortcuts

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