jwt

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	McsHmacJWTSecret            = "MCS_HMAC_JWT_SECRET"
	McsSTSAndJWTDurationSeconds = "MCS_STS_AND_JWT_DURATION_SECONDS"
	McsPBKDFPassphrase          = "MCS_PBKDF_PASSPHRASE"
	McsPBKDFSalt                = "MCS_PBKDF_SALT"
)

Variables

This section is empty.

Functions

func GetHmacJWTSecret

func GetHmacJWTSecret() string

GetHmacJWTSecret returns the 64 bytes secret used for signing the generated JWT for the application

func GetMcsSTSAndJWTDurationInSeconds

func GetMcsSTSAndJWTDurationInSeconds() int

McsSTSAndJWTDurationSeconds returns the default session duration for the STS requested tokens and the generated JWTs. Ideally both values should match so jwt and Minio sts sessions expires at the same time.

func GetMcsSTSAndJWTDurationTime

func GetMcsSTSAndJWTDurationTime() time.Duration

GetMcsSTSAndJWTDurationTime returns GetMcsSTSAndJWTDurationInSeconds in duration format

func GetPBKDFPassphrase

func GetPBKDFPassphrase() string

GetPBKDFPassphrase returns passphrase for the pbkdf2 function used to encrypt JWT payload

func GetPBKDFSalt

func GetPBKDFSalt() string

GetPBKDFSalt returns salt for the pbkdf2 function used to encrypt JWT payload

func ParseWithClaims

func ParseWithClaims(tokenStr string, claims *MapClaims) error

ParseWithClaims - parse the token string, valid methods.

Types

type MapClaims

type MapClaims struct {
	Data    string `json:"data,omitempty"`
	Subject string `json:"sub,omitempty"`
	jwtgo.MapClaims
}

MapClaims - implements custom unmarshaller

func NewMapClaims

func NewMapClaims() *MapClaims

NewMapClaims - Initializes a new map claims

func (*MapClaims) Lookup

func (c *MapClaims) Lookup(key string) (value string, ok bool)

Lookup returns the value and if the key is found.

func (*MapClaims) Map

func (c *MapClaims) Map() map[string]interface{}

Map returns underlying low-level map claims.

func (*MapClaims) MarshalJSON

func (c *MapClaims) MarshalJSON() ([]byte, error)

MarshalJSON marshals the MapClaims struct

func (*MapClaims) SetData

func (c *MapClaims) SetData(data string)

SetData sets the "Data" custom field.

func (*MapClaims) SetExpiry

func (c *MapClaims) SetExpiry(t time.Time)

SetExpiry sets expiry in unix epoch secs

func (*MapClaims) Valid

func (c *MapClaims) Valid() error

Valid - implements https://godoc.org/github.com/dgrijalva/jwt-go#Claims compatible claims interface, additionally validates "Data" field.

type SigningMethodHMAC

type SigningMethodHMAC struct {
	Name string
	Hash crypto.Hash
}

SigningMethodHMAC - Implements the HMAC-SHA family of signing methods signing methods Expects key type of []byte for both signing and validation

var (
	SigningMethodHS256 *SigningMethodHMAC
	SigningMethodHS384 *SigningMethodHMAC
	SigningMethodHS512 *SigningMethodHMAC
)

Specific instances for HS256, HS384, HS512

type StandardClaims

type StandardClaims struct {
	Data string `json:"data,omitempty"`
	jwtgo.StandardClaims
}

StandardClaims are basically standard claims with "Data"

func NewStandardClaims

func NewStandardClaims() *StandardClaims

NewStandardClaims - initializes standard claims

func (*StandardClaims) SetAudience

func (c *StandardClaims) SetAudience(aud string)

SetAudience sets audience for these claims

func (*StandardClaims) SetData

func (c *StandardClaims) SetData(data string)

SetData sets the "Data" custom field.

func (*StandardClaims) SetExpiry

func (c *StandardClaims) SetExpiry(t time.Time)

SetExpiry sets expiry in unix epoch secs

func (*StandardClaims) SetIssuer

func (c *StandardClaims) SetIssuer(issuer string)

SetIssuer sets issuer for these claims

func (*StandardClaims) SetSubject

func (c *StandardClaims) SetSubject(subject string)

SetSubject sets unique identifier for the jwt

func (*StandardClaims) Valid

func (c *StandardClaims) Valid() error

Valid - implements https://godoc.org/github.com/dgrijalva/jwt-go#Claims compatible claims interface, additionally validates "Data" field.

Jump to

Keyboard shortcuts

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