client

package module
v0.0.0-...-b97cff1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

Encryptonize Go Client Library v3.2.0

A simple Encryptonize go client library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for making gRPC calls to the Encryptonize service.

func NewClient

func NewClient(ctx context.Context, endpoint, certPath string) (*Client, error)

NewClient creates a new Encryptonize client. Note that in order to call endpoints that require authentication, you need to call `LoginUser` first.

func (*Client) AddPermission

func (c *Client) AddPermission(oid, target string) error

AddPermission grants permission for the `target` to the requested object.

func (*Client) AddUserToGroup

func (c *Client) AddUserToGroup(uid, gid string) error

AddUserToGroup adds a user to a group.

func (*Client) Close

func (c *Client) Close() error

Close closes all connections to the Encryptonize server.

func (*Client) CreateGroup

func (c *Client) CreateGroup(scopes []Scope) (*CreateGroupResponse, error)

CreateGroup creates a new Encryptonize group with the requested scopes.

func (*Client) CreateUser

func (c *Client) CreateUser(scopes []Scope) (*CreateUserResponse, error)

CreateUser creates a new Encryptonize user with the requested scopes.

func (*Client) Decrypt

func (c *Client) Decrypt(objectID string, ciphertext, associatedData []byte) (*DecryptResponse, error)

Decrypt decrypts a previously encrypted `ciphertext` and verifies the integrity of the `ciphertext` and `associatedData`.

func (*Client) Delete

func (c *Client) Delete(oid string) error

Delete removes previously stored data from the Encryptonize service.

func (*Client) Encrypt

func (c *Client) Encrypt(plaintext, associatedData []byte) (*EncryptResponse, error)

Encrypt encrypts the `plaintext` and tags both `plaintext` and `associatedData` returning the resulting ciphertext.

func (*Client) GetPermissions

func (c *Client) GetPermissions(oid string) (*GetPermissionsResponse, error)

GetPermissions returns a list of IDs that have access to the requested object.

func (*Client) GetTokenExpiration

func (c *Client) GetTokenExpiration() time.Time

GetTokenExpiration returns when the current token wil expire.

func (*Client) Health

func (c *Client) Health() (*HealthResponse, error)

Health retrieves the current health status of the Encryptonize service.

func (*Client) LoginUser

func (c *Client) LoginUser(uid, password string) error

LoginUser authenticates to the Encryptonize service with the given credentials and sets the resulting access token for future calls. Call `LoginUser` again to switch to a different user.

func (*Client) RemovePermission

func (c *Client) RemovePermission(oid, target string) error

RemovePermission removes permissions for the `target` to the requested object.

func (*Client) RemoveUser

func (c *Client) RemoveUser(uid string) error

RemoveUser removes a user from the Encryptonize service.

func (*Client) RemoveUserFromGroup

func (c *Client) RemoveUserFromGroup(uid, gid string) error

RemoveUserFromGroup removes a user from a group.

func (*Client) Retrieve

func (c *Client) Retrieve(oid string) (*RetrieveResponse, error)

Retrieve decrypts a previously stored object returning the ciphertext.

func (*Client) SetToken

func (c *Client) SetToken(token string)

SetToken sets the provided token as the authentication header.

func (*Client) Store

func (c *Client) Store(plaintext, associatedData []byte) (*StoreResponse, error)

Store encrypts the `plaintext` and tags both `plaintext` and `associatedData` storing the resulting ciphertext in the Encryptonize service.

func (*Client) Update

func (c *Client) Update(oid string, plaintext, associatedData []byte) error

Update replaces the currently stored data of an object with the specified `plaintext` and `associatedData`.

func (*Client) Version

func (c *Client) Version() (*VersionResponse, error)

Version retrieves the version information of the Encryptonize service.

type ClientWR

type ClientWR struct {
	Client
	// contains filtered or unexported fields
}

ClientWR for making gRPC calls to the Encryptonize service while automatically refreshing the access token.

func NewClientWR

func NewClientWR(ctx context.Context, endpoint, certPath, uid, password string) (*ClientWR, error)

NewClientWR creates a new Encryptonize client. In order to switch credentials to another user, use `LoginUser`.

func (*ClientWR) AddPermission

func (c *ClientWR) AddPermission(oid, target string) error

AddPermission grants permission for the `target` to the requested object.

func (*ClientWR) AddUserToGroup

func (c *ClientWR) AddUserToGroup(uid, gid string) error

AddUserToGroup adds a user to a group.

func (*ClientWR) CreateGroup

func (c *ClientWR) CreateGroup(scopes []Scope) (*CreateGroupResponse, error)

CreateGroup creates a new Encryptonize group with the requested scopes.

func (*ClientWR) CreateUser

func (c *ClientWR) CreateUser(scopes []Scope) (*CreateUserResponse, error)

CreateUser creates a new Encryptonize user with the requested scopes.

func (*ClientWR) Decrypt

func (c *ClientWR) Decrypt(objectID string, ciphertext, associatedData []byte) (*DecryptResponse, error)

Decrypt decrypts a previously encrypted `ciphertext` and verifies the integrity of the `ciphertext` and `associatedData`.

func (*ClientWR) Delete

func (c *ClientWR) Delete(oid string) error

Delete removes previously stored data from the Encryptonize service.

func (*ClientWR) Encrypt

func (c *ClientWR) Encrypt(plaintext, associatedData []byte) (*EncryptResponse, error)

Encrypt encrypts the `plaintext` and tags both `plaintext` and `associatedData` returning the resulting ciphertext.

func (*ClientWR) GetPermissions

func (c *ClientWR) GetPermissions(oid string) (*GetPermissionsResponse, error)

GetPermissions returns a list of IDs that have access to the requested object.

func (*ClientWR) Health

func (c *ClientWR) Health() (*HealthResponse, error)

Health retrieves the current health status of the Encryptonize service.

func (*ClientWR) LoginUser

func (c *ClientWR) LoginUser(uid, password string) error

LoginUser authenticates to the Encryptonize service with the given credentials and sets the resulting access token for future calls. Call `LoginUser` again to switch to a different user.

func (*ClientWR) RemovePermission

func (c *ClientWR) RemovePermission(oid, target string) error

RemovePermission removes permissions for the `target` to the requested object.

func (*ClientWR) RemoveUser

func (c *ClientWR) RemoveUser(uid string) error

RemoveUser removes a user from the Encryptonize service.

func (*ClientWR) RemoveUserFromGroup

func (c *ClientWR) RemoveUserFromGroup(uid, gid string) error

RemoveUserFromGroup removes a user from a group.

func (*ClientWR) Retrieve

func (c *ClientWR) Retrieve(oid string) (*RetrieveResponse, error)

Retrieve decrypts a previously stored object returning the ciphertext.

func (*ClientWR) Store

func (c *ClientWR) Store(plaintext, associatedData []byte) (*StoreResponse, error)

Store encrypts the `plaintext` and tags both `plaintext` and `associatedData` storing the resulting ciphertext in the Encryptonize service.

func (*ClientWR) Update

func (c *ClientWR) Update(oid string, plaintext, associatedData []byte) error

Update replaces the currently stored data of an object with the specified `plaintext` and `associatedData`.

func (*ClientWR) Version

func (c *ClientWR) Version() (*VersionResponse, error)

Version retrieves the version information of the Encryptonize service.

type CreateGroupResponse

type CreateGroupResponse struct {
	GroupID string `json:"groupId"`
}

type CreateUserResponse

type CreateUserResponse struct {
	UserID   string `json:"userId"`
	Password string `json:"password"`
}

type DecryptResponse

type DecryptResponse struct {
	Plaintext      []byte `json:"plaintext"`
	AssociatedData []byte `json:"associatedData"`
}

type EncryptResponse

type EncryptResponse struct {
	Ciphertext     []byte `json:"ciphertext"`
	AssociatedData []byte `json:"associatedData"`
	ObjectID       string `json:"objectId"`
}

type GetPermissionsResponse

type GetPermissionsResponse struct {
	GroupIDs []string `json:"groupIds"`
}

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

type RetrieveResponse

type RetrieveResponse struct {
	Plaintext      []byte `json:"plaintext"`
	AssociatedData []byte `json:"associatedData"`
}

type Scope

type Scope int
const (
	ScopeRead Scope = iota
	ScopeCreate
	ScopeUpdate
	ScopeDelete
	ScopeIndex
	ScopeObjectPermissions
	ScopeUserManagement
)

type StoreResponse

type StoreResponse struct {
	ObjectID string `json:"objectId"`
}

type VersionResponse

type VersionResponse struct {
	Commit string `json:"commit"`
	Tag    string `json:"tag"`
}

Jump to

Keyboard shortcuts

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