storage

package
v0.0.0-...-c6a76a1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	HashPassword  []byte
	Key           []byte
	Cost          int
	HmacConf      *HmacConfig
	Rnd           *rand.Rand
	JwtConf       *JwtConfig
	Base64Encoder *base64.Encoding
}

AppConfig use for holding the Application configuration

func (*AppConfig) CheckSignMsg

func (conf *AppConfig) CheckSignMsg(token, oldSign []byte) (bool, error)

CheckSignMsg use for checking the sign of received token with existing token

func (*AppConfig) ComparePassAndHash

func (conf *AppConfig) ComparePassAndHash(password string) error

ComparePassAndHash for comparing hashPass and password

func (*AppConfig) CreateSignedToken

func (conf *AppConfig) CreateSignedToken(uc *UserClaims) (string, error)

CreateSignedToken use for creating JWT token

func (*AppConfig) DecodingBase64

func (conf *AppConfig) DecodingBase64(encodedStr string) ([]byte, error)

DecodingBase64 use for decoding our msg to base64 for using alongside of another functionalities

func (*AppConfig) EncodingBase64

func (conf *AppConfig) EncodingBase64(encoding *base64.Encoding, msg string) string

EncodingBase64 use for encoding our msg to base64 for using alongside of another functionalities

func (*AppConfig) EncryptSHA256File

func (conf *AppConfig) EncryptSHA256File(filepath string) ([]byte, error)

EncryptSHA256File use for encrypting a file with sha256 method

func (*AppConfig) GenerateHash

func (conf *AppConfig) GenerateHash(password string) error

GenerateHash with bcrypt package

func (*AppConfig) HmacSigToken

func (conf *AppConfig) HmacSigToken(token []byte) ([]byte, error)

HmacSigToken use for sign specific token and then return signed token

func (*AppConfig) KeyGenerator

func (conf *AppConfig) KeyGenerator()

KeyGenerator use for creating the key from bytes storage

func (*AppConfig) ParseSignedToken

func (conf *AppConfig) ParseSignedToken(signedToken string) (*UserClaims, error)

ParseSignedToken use for parsing the signed token to our claims

func (*AppConfig) UUIDKeyGenerator

func (conf *AppConfig) UUIDKeyGenerator()

UUIDKeyGenerator use random bytes that generates by KeyGenerator function then create uuid based on that

type HmacConfig

type HmacConfig struct {
	HashMethod    func() hash.Hash
	HashAlgorithm hash.Hash
	HmacSigner    hash.Hash
}

HmacConfig use for holding the HMAC configurations

type JwtConfig

type JwtConfig struct {
	JwtKeyMethod jwt.SigningMethod
}

JwtConfig use for holding the jwt configurations

type UserClaims

type UserClaims struct {
	jwt.StandardClaims
	SessionID int64
}

UserClaims default claims based on jwt.StandardClaims

func (*UserClaims) Valid

func (u *UserClaims) Valid() error

Valid check the validation for our JWT token

Jump to

Keyboard shortcuts

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