Documentation ¶
Index ¶
- Variables
- func Detokenize(token string, cypher map[string]string) (string, error)
- func GenAlphaNumericString(n int) string
- func GetCombinedKey(s ...string) (cs string)
- func IsErrKeyAlreadyExist(err error) bool
- func WithStore(store store.Store) func(*Manager)
- type Manager
- func (m *Manager) DeleteTokenByID(ctx context.Context, id string) (bool, error)
- func (m *Manager) Detokenize(ctx context.Context, key, token string) (bool, string, error)
- func (m *Manager) GenerateCipher() error
- func (m *Manager) GetAllTokens(ctx context.Context) ([]*model.Tokenize, error)
- func (m *Manager) GetTokenByID(ctx context.Context, id string) (*model.Tokenize, error)
- func (m *Manager) PatchTokenByID(ctx context.Context, key, val string) (string, error)
- func (m *Manager) Tokenize(ctx context.Context, key, val string) (string, error)
- func (m *Manager) Validate(ctx context.Context, token *model.Tokenize, patch bool) ([]*ValidateResponse, bool)
- func (m *Manager) ValidateKeys(ctx context.Context, token *model.Tokenize) ([]*ValidateResponse, bool)
- type Options
- type Token
- type ValidateResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyAlreadyExists = errors.New("key already exists. not overriding") ErrKeyDoesNotExists = "key %s does not exist" ErrDuplicateKeys = errors.New("key already exists in request. accepted only the first one") )
var ( DefaultCipherLoc = "./.cipher" EnvKeyAESCipher = "CIPHER" EnvKeyInitializationVector = "IV" KeyDelimiter = "__" )
var ( ErrCipherToken404AES = errors.New("aes cipher not found in cipher map") ErrCipherToken404IV = errors.New("initialization vector (IV) not found in cipher map") ErrTokenInvalidPadding = errors.New("invalid token string: padded bytes larger than aes block size: 16") ErrTokenInvalidPaddingNotHomogeneous = errors.New("invalid token string: padded bytes are not all the same") ErrTokenInvalidBlockSize = errors.New("invalid token string: decrypted bytes size is not a multiple of the block size") )
Functions ¶
func GenAlphaNumericString ¶
GenAlphaNumericString mimics strings.Builder with package unsafe. According to the author it is one of the pastest implementation of strings builder.
func GetCombinedKey ¶
GetCombinedKey creates a key string unique to every value in the request object. This key string is a concatenation of all the parent keys that constitute the request data
func IsErrKeyAlreadyExist ¶
IsErrKeyAlreadyExist enables easy checking of error
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
NewManager creates a new instance of Manager. It manages token operations (retrieval, storage, servicing) throughout the lifetime of the server.
func (*Manager) DeleteTokenByID ¶
DeleteTokenByID deletes the token from the store identified by ID
func (*Manager) Detokenize ¶
Detokenize retrieves the value represented by a particular token, identified by the particular key
func (*Manager) GenerateCipher ¶
GenerateCipher generates a new AES cipher and Initialization Vector pais, and persists it to disk
func (*Manager) GetAllTokens ¶
GetAllTokens returns all tokens currently in the store
func (*Manager) GetTokenByID ¶
GetTokenByID returns the token owned by a specific ID/Key
func (*Manager) PatchTokenByID ¶
PatchTokenByID updates a token in the store identified by ID
func (*Manager) Tokenize ¶
Tokenize manages the tokenization, and stores generated tokens in an internal store, for easy retrieval
func (*Manager) Validate ¶
func (m *Manager) Validate(ctx context.Context, token *model.Tokenize, patch bool) ([]*ValidateResponse, bool)
Validate is the high level api for validating all the user provided data
func (*Manager) ValidateKeys ¶
func (m *Manager) ValidateKeys(ctx context.Context, token *model.Tokenize) ([]*ValidateResponse, bool)
ValidateKeys validates the Keys used in the request, ensuring it doesn't already exist, and that it conforms with the standards.
type ValidateResponse ¶
ValidateResponse holds the error response from validation and the associated key.