v0.0.6 Latest Latest

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 7 Imported by: 0



Package security provides security related things.



This section is empty.


This section is empty.


func GetPrivateKey

func GetPrivateKey(signingMethod string) (interface{}, error)

GetPrivateKey returns a private key configured for a signing method.

func GetPublicKey

func GetPublicKey(signingMethod string) (interface{}, error)

GetPublicKey returns a public key configured for a signing method.

func GetSigningMethod

func GetSigningMethod() jwt.SigningMethod

GetSigningMethod returns a default signing method.

func GetTokenSignedString

func GetTokenSignedString(t *jwt.Token) (string, error)

GetTokenSignedString returns a token as a signed string.

func InitFromConfig

func InitFromConfig(cfg config.Config) error

InitFromConfig initializes security from config.

func NewToken

func NewToken() *jwt.Token

NewToken creates a new JWT token without claims section.

func NewTokenWithClaims

func NewTokenWithClaims(claims jwt.Claims) *jwt.Token

NewTokenWithClaims creates a new JWT token with claims section.

func ParseToken

func ParseToken(s string) (*jwt.Token, error)

ParseToken parses a signed token string without claims section.

func ParseTokenWithClaims

func ParseTokenWithClaims(s string, claims jwt.Claims) (*jwt.Token, error)

ParseTokenWithClaims parses a signed token string with claims section.

func SetECDSAPrivateKey

func SetECDSAPrivateKey(k []byte) error

SetECDSAPrivateKey sets an ECDSA private key.

func SetECDSAPublicKey

func SetECDSAPublicKey(k []byte) error

SetECDSAPublicKey sets an ECDSA public key.

func SetHMACKey

func SetHMACKey(k []byte)

SetHMACKey sets an HMAC key.

func SetRSAPrivateKey

func SetRSAPrivateKey(k []byte) error

SetRSAPrivateKey sets an RSA private key.

func SetRSAPublicKey

func SetRSAPublicKey(k []byte) error

SetRSAPublicKey sets an RSA public key.

func SetSigningMethod

func SetSigningMethod(alg string) error

SetSigningMethod sets a default signing method.


This section is empty.

Jump to

Keyboard shortcuts

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