authclient

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LIBVERSION               = "1.0.0"
	ErrFatal                 = "fatal error"
	ErrInvalidHeaderSignatur = "invalid header signature"
)

LIBVERSION is version of library

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(encryptedText string, keyContent string) (string, error)

func DecryptData

func DecryptData(text string, key string) string

DecryptData encrypt text with key input

func Encrypt

func Encrypt(plainText string, keyContent string) (string, error)

func EncryptData

func EncryptData(text string, key string) string

EncryptData encrypt text with key input

func GenerateHMac

func GenerateHMac(message string, key string) (string, error)

func GenerateTokenTypeH added in v1.0.14

func GenerateTokenTypeH(requestData string, key string, dtNowWithTimezone time.Time, isRequestDataEncrypt bool) (string, string, error)

GenerateTokenTypeH use for Host to Host request short life time 60 secconds params: requestData type: string description: string or json string to generate token type H with request data params: key type: string description: key content get from T2P params: dtNowWithTimezone type: time.Time description: current date time with server time zone eg. "Asia/Bangkok" params: isRequestDataEncrypt type: bool description: will requestData be encrypted or plaintext for secure use encrypt

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

PKCS5Padding is a function for padding string

func PKCS5Unpadding

func PKCS5Unpadding(origData []byte) []byte

PKCS5Unpadding is a function for unpadding string

func PrepareRequest

func PrepareRequest(hashInfo map[string]string, body, key string, isEncryptBody bool) string

PrepareRequest is a function for preparing requests to call APIs

func RequestTokenTypeC added in v1.0.14

func RequestTokenTypeC(tokenReferenceData string, key string, dtNowWithTimezone time.Time, authUrl string) (string, error)

RequestTokenTypeC use for Host to Host request short life time 60 secconds params: tokenReferenceData type: string description: short reference for tracing if needed params: key type: string description: key content get from T2P params: dtNowWithTimezone type: time.Time description: current date time with server time zone eg. "Asia/Bangkok" params: authUrl type: string description: T2P authen server URL (UAT) `https://test-api-authen.t2p.co.th/authen/v1/clientToken/generate`, (PROD) `https://api-authen.t2p.co.th/authen/v1/clientToken/generate`

func VerifyHMac

func VerifyHMac(message string, hMac string, key string) (bool, error)

Types

type DataPrepare

type DataPrepare struct {
	Body   string `json:"body"`
	Header string `json:"header"`
}

DataPrepare data part

type KeyInfor

type KeyInfor struct {
	KeyContents       string              `json:"keyContents"`
	KeyAuthorize      map[string][]string `json:"keyAuthorize"`
	RequireInfo       map[string]string   `json:"requireInfo"`
	TokenTimeout      map[string]int      `json:"tokenTimeout"`
	HostTokenTimeZone string              `json:"hostTokenTimeZone"`
}

KeyInfor key infor to redis

type MetaPrepare

type MetaPrepare struct {
	Language        string `json:"language"`
	ResponseCode    int    `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	Version         string `json:"version"`
}

MetaPrepare meta part

type ResponsePreparePayload

type ResponsePreparePayload struct {
	Meta MetaPrepare `json:"meta"`
	Data DataPrepare `json:"data"`
}

ResponsePreparePayload main payload

Jump to

Keyboard shortcuts

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