authhack

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JWTExports = map[string]interface{}{
	"ALG_NONE":  "None",
	"ALG_ES256": "ES256",
	"ALG_ES384": "ES384",
	"ALG_ES512": "ES512",
	"ALG_HS256": "HS256",
	"ALG_HS384": "HS384",
	"ALG_HS512": "HS512",
	"ALG_RS256": "RS256",
	"ALG_RS384": "RS384",
	"ALG_RS512": "RS512",
	"ALG_PS256": "PS256",
	"ALG_PS384": "PS384",
	"ALG_PS512": "PS512",

	"Parse": JwtParse,
	"JWTGenerate": func(alg string, i interface{}, key []byte) (string, error) {
		return JwtGenerate(alg, utils.InterfaceToMapInterface(i), "JWT", key)
	},
	"JWTGenerateEx": func(alg string, extraHeader, i interface{}, key []byte) (string, error) {
		return JwtGenerateEx(alg, utils.InterfaceToMapInterface(extraHeader), utils.InterfaceToMapInterface(i), "JWT", key)
	},
	"JWSGenerate": func(alg string, i interface{}, key []byte) (string, error) {
		return JwtGenerate(alg, utils.InterfaceToMapInterface(i), "JWS", key)
	},
	"JWSGenerateEx": func(alg string, extraHeader, i interface{}, key []byte) (string, error) {
		return JwtGenerateEx(alg, utils.InterfaceToMapInterface(extraHeader), utils.InterfaceToMapInterface(i), "JWS", key)
	},
	"RemoveAlg": JwtChangeAlgToNone,
	"AllAlgs":   AvailableJWTTokensAlgs,
}
View Source
var (
	JwtAlgs = []jwt.SigningMethod{
		jwt.SigningMethodES384,
		jwt.SigningMethodES256,
		jwt.SigningMethodES512,

		jwt.SigningMethodHS256,
		jwt.SigningMethodHS384,
		jwt.SigningMethodHS512,

		jwt.SigningMethodPS256,
		jwt.SigningMethodPS384,
		jwt.SigningMethodPS512,

		jwt.SigningMethodRS256,
		jwt.SigningMethodRS384,
		jwt.SigningMethodRS512,

		&AuthHackJWTSigningNone{},
	}
)

Functions

func AvailableJWTTokensAlgs

func AvailableJWTTokensAlgs() []string

func JwtChangeAlgToNone

func JwtChangeAlgToNone(token string) (string, error)

func JwtGenerate

func JwtGenerate(alg string, extraData map[string]interface{}, typ string, key []byte) (string, error)

func JwtGenerateEx added in v1.2.2

func JwtGenerateEx(alg string, extraHeader map[string]interface{}, extraData map[string]interface{}, typ string, key []byte) (string, error)

func JwtParse

func JwtParse(tokenStr string, keys ...string) (*jwt.Token, []byte, error)

func NewJWTHelper

func NewJWTHelper(alg string) (*jwt.Token, error)

Types

type AuthHackJWTSigningNone

type AuthHackJWTSigningNone struct{}

Implements the none signing method. This is required by the spec but you probably should never use it.

func (*AuthHackJWTSigningNone) Alg

func (m *AuthHackJWTSigningNone) Alg() string

func (*AuthHackJWTSigningNone) Sign

func (m *AuthHackJWTSigningNone) Sign(signingString string, key interface{}) (string, error)

Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key

func (*AuthHackJWTSigningNone) Verify

func (m *AuthHackJWTSigningNone) Verify(signingString, signature string, key interface{}) (err error)

Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key

Jump to

Keyboard shortcuts

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