Documentation ¶
Index ¶
- Variables
- func ApplyKwargs(struct1 interface{}, kwargs map[string]interface{}) error
- func B64decode(encoded []byte) ([]byte, error)
- func B64encode(msg []byte) string
- func ByteCompare(a, b []byte) bool
- func Bytes2Int(_byte []byte) (_int int64)
- func Compress(src []byte) []byte
- func Concentrate(b ...interface{}) ([]byte, error)
- func DumpPayload(vx interface{}, api interface{}) (string, error)
- func Int2Bytes(_int int64) (bs []byte)
- func IsValidStruct(t interface{}) bool
- func LoadPayload(payload []byte, api interface{}) (interface{}, error)
- func PreURLSafeDumpPayload(JSONPayload []byte) ([]byte, error)
- func PreURLSafeLoadPayload(payload []byte) ([]byte, error)
- func RSplit(b, sep []byte) ([]byte, []byte)
- func URLSafeDumpPayload(obj interface{}, api interface{}) (string, error)
- func URLSafeLoadPayload(payload []byte, api interface{}) (interface{}, error)
- func UnCompress(data []byte) ([]byte, error)
- func WantBytes(str string, chartype ...interface{}) []byte
- type HMACAlgorithm
- type JSON
- type JSONAPI
- type JSONWebSignatureSerializer
- func (jwss JSONWebSignatureSerializer) DumpPayload(header, obj interface{}) ([]byte, error)
- func (jwss JSONWebSignatureSerializer) Dumps(obj interface{}, args ...interface{}) ([]byte, error)
- func (jwss JSONWebSignatureSerializer) GetIssueDate(t int64) string
- func (jwss JSONWebSignatureSerializer) LoadPayload(payload []byte) (interface{}, interface{}, error)
- func (jwss JSONWebSignatureSerializer) Loads(s string) (interface{}, interface{}, error)
- func (jwss JSONWebSignatureSerializer) MakeHeader(headerfields map[string]interface{}) map[string]interface{}
- func (jwss JSONWebSignatureSerializer) MakeSigner() Signer
- func (jwss *JSONWebSignatureSerializer) SetDefault()
- func (jwss JSONWebSignatureSerializer) TimedDumps(obj interface{}, args ...interface{}) ([]byte, error)
- func (jwss JSONWebSignatureSerializer) TimedLoads(s string) (map[string]interface{}, interface{}, error)
- func (jwss JSONWebSignatureSerializer) TimedMakeHeader(headerfields map[string]interface{}) map[string]interface{}
- type Serializer
- func (ser Serializer) Dumps(objx interface{}) ([]byte, error)
- func (ser Serializer) IterUnSigners() []interface{}
- func (ser Serializer) Loads(s string) (interface{}, error)
- func (ser Serializer) PreDumps(objx interface{}, dumpfunc func(interface{}, interface{}) (string, error)) ([]byte, error)
- func (ser Serializer) PreLoads(s string, loadfunc func([]byte, interface{}) (interface{}, error)) (interface{}, error)
- func (ser Serializer) PreTimedDumps(objx interface{}, dumpfunc func(interface{}, interface{}) (string, error)) ([]byte, error)
- func (ser Serializer) PreTimedLoads(s string, MaxAge int64, ...) (interface{}, error)
- func (ser *Serializer) SetDefault()
- func (ser Serializer) TimedDumps(objx interface{}) ([]byte, error)
- func (ser Serializer) TimedLoads(s string, MaxAge int64) (interface{}, error)
- func (ser Serializer) URLSafeDumps(objx interface{}) ([]byte, error)
- func (ser Serializer) URLSafeLoads(s string) (interface{}, error)
- func (ser Serializer) URLSafeTimedDumps(objx interface{}) ([]byte, error)
- func (ser Serializer) URLSafeTimedLoads(s string, MaxAge int64) (interface{}, error)
- type Signature
- type Signer
- func (signer *Signer) DeriveKey() ([]byte, error)
- func (signer Signer) GetSignature(value []byte) []byte
- func (signer Signer) GetTimestamp() int64
- func (signer *Signer) SetDefault()
- func (signer Signer) Sign(value string) []byte
- func (signer Signer) SignTimestamp(values string) []byte
- func (signer Signer) UnSign(signedvalues string) ([]byte, error)
- func (signer Signer) UnSignTimestamp(values string, MaxAge int64) ([]byte, int64, error)
- func (signer Signer) Validate(signedvalues string) bool
- func (signer Signer) ValidateTimestamp(signedvalue string, MaxAge int64) bool
- func (signer Signer) VerifySignature(value []byte, sig []byte) bool
- type SigningAlgorithm
Constants ¶
This section is empty.
Variables ¶
View Source
var ( JwsAlgorithms = map[string]interface{}{ "HS256": HMACAlgorithm{DigestMethod: sha256.New}, "HS384": HMACAlgorithm{DigestMethod: sha512.New384}, "HS512": HMACAlgorithm{DigestMethod: sha512.New}, "none": SigningAlgorithm{}, } DefaultAlgorithm = "HS512" DefaultSerializer = JSON{} DefaultExpiresIn int64 = 3600 )
View Source
var ( Sep = []byte(".") DefaultFallbackSigners = []map[string]interface{}{{"DigestMethod": sha512.New}} )
View Source
var ( BlankBytes = []byte("") DefaultSep = "." )
View Source
var Base64Alphabet = WantBytes("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_=")
Functions ¶
func ApplyKwargs ¶
func ByteCompare ¶
func Concentrate ¶
func DumpPayload ¶
func IsValidStruct ¶
func IsValidStruct(t interface{}) bool
func LoadPayload ¶
func PreURLSafeDumpPayload ¶
func PreURLSafeLoadPayload ¶
func URLSafeDumpPayload ¶
func URLSafeLoadPayload ¶
func UnCompress ¶
Types ¶
type HMACAlgorithm ¶
func (HMACAlgorithm) GetSignature ¶
func (ha HMACAlgorithm) GetSignature(key, value []byte) []byte
func (HMACAlgorithm) VerifySignature ¶
func (ha HMACAlgorithm) VerifySignature(key, value, sig []byte) bool
type JSONAPI ¶
type JSONAPI interface { Load(data []byte) (interface{}, error) Dump(v interface{}) (string, error) }
JSONAPI used to solve the problem that applying new struct to `serializer` or `jws`
type JSONWebSignatureSerializer ¶
type JSONWebSignatureSerializer struct { Secret string Salt string Serializer JSONAPI Signer Signer AlgorithmName string Algorithm Signature ExpiresIn int64 }
func (JSONWebSignatureSerializer) DumpPayload ¶
func (jwss JSONWebSignatureSerializer) DumpPayload(header, obj interface{}) ([]byte, error)
func (JSONWebSignatureSerializer) Dumps ¶
func (jwss JSONWebSignatureSerializer) Dumps(obj interface{}, args ...interface{}) ([]byte, error)
func (JSONWebSignatureSerializer) GetIssueDate ¶
func (jwss JSONWebSignatureSerializer) GetIssueDate(t int64) string
func (JSONWebSignatureSerializer) LoadPayload ¶
func (jwss JSONWebSignatureSerializer) LoadPayload(payload []byte) (interface{}, interface{}, error)
func (JSONWebSignatureSerializer) Loads ¶
func (jwss JSONWebSignatureSerializer) Loads(s string) (interface{}, interface{}, error)
func (JSONWebSignatureSerializer) MakeHeader ¶
func (jwss JSONWebSignatureSerializer) MakeHeader(headerfields map[string]interface{}) map[string]interface{}
func (JSONWebSignatureSerializer) MakeSigner ¶
func (jwss JSONWebSignatureSerializer) MakeSigner() Signer
func (*JSONWebSignatureSerializer) SetDefault ¶
func (jwss *JSONWebSignatureSerializer) SetDefault()
func (JSONWebSignatureSerializer) TimedDumps ¶
func (jwss JSONWebSignatureSerializer) TimedDumps(obj interface{}, args ...interface{}) ([]byte, error)
func (JSONWebSignatureSerializer) TimedLoads ¶
func (jwss JSONWebSignatureSerializer) TimedLoads(s string) (map[string]interface{}, interface{}, error)
func (JSONWebSignatureSerializer) TimedMakeHeader ¶
func (jwss JSONWebSignatureSerializer) TimedMakeHeader(headerfields map[string]interface{}) map[string]interface{}
type Serializer ¶
type Serializer struct { Secret string Salt string SerializerOP JSONAPI // Can override it becomes easier Signer Signer Signerkwargs map[string]interface{} FallbackSigners []map[string]interface{} }
func (Serializer) Dumps ¶
func (ser Serializer) Dumps(objx interface{}) ([]byte, error)
func (Serializer) IterUnSigners ¶
func (ser Serializer) IterUnSigners() []interface{}
func (Serializer) Loads ¶
func (ser Serializer) Loads(s string) (interface{}, error)
func (Serializer) PreDumps ¶
func (ser Serializer) PreDumps(objx interface{}, dumpfunc func(interface{}, interface{}) (string, error)) ([]byte, error)
func (Serializer) PreLoads ¶
func (ser Serializer) PreLoads(s string, loadfunc func([]byte, interface{}) (interface{}, error)) (interface{}, error)
func (Serializer) PreTimedDumps ¶
func (ser Serializer) PreTimedDumps(objx interface{}, dumpfunc func(interface{}, interface{}) (string, error)) ([]byte, error)
func (Serializer) PreTimedLoads ¶
func (*Serializer) SetDefault ¶
func (ser *Serializer) SetDefault()
func (Serializer) TimedDumps ¶
func (ser Serializer) TimedDumps(objx interface{}) ([]byte, error)
func (Serializer) TimedLoads ¶
func (ser Serializer) TimedLoads(s string, MaxAge int64) (interface{}, error)
func (Serializer) URLSafeDumps ¶
func (ser Serializer) URLSafeDumps(objx interface{}) ([]byte, error)
func (Serializer) URLSafeLoads ¶
func (ser Serializer) URLSafeLoads(s string) (interface{}, error)
func (Serializer) URLSafeTimedDumps ¶
func (ser Serializer) URLSafeTimedDumps(objx interface{}) ([]byte, error)
func (Serializer) URLSafeTimedLoads ¶
func (ser Serializer) URLSafeTimedLoads(s string, MaxAge int64) (interface{}, error)
type Signer ¶
type Signer struct { Secret string Salt string Sep string SecretBytes []byte SaltBytes []byte SepBytes []byte KeyDerivation string // concat, django-concat, hmac DigestMethod func() hash.Hash Algorithm Signature // HMACAlgorithm, NoneAlgorithm }
func (Signer) GetSignature ¶
func (Signer) GetTimestamp ¶
func (*Signer) SetDefault ¶
func (signer *Signer) SetDefault()
func (Signer) SignTimestamp ¶
func (Signer) UnSignTimestamp ¶
func (Signer) ValidateTimestamp ¶
type SigningAlgorithm ¶
type SigningAlgorithm struct { }
func (SigningAlgorithm) GetSignature ¶
func (sa SigningAlgorithm) GetSignature(key, value []byte) []byte
func (SigningAlgorithm) VerifySignature ¶
func (sa SigningAlgorithm) VerifySignature(key, value, sig []byte) bool
Click to show internal directories.
Click to hide internal directories.