postgres

package
v0.0.0-...-d4747eb Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package postgres provides gophkeeper implementation with postgresql database storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBlobsDir

func WithBlobsDir(dir string) option

WithBlobsDir sets blobs dir to the gophkeeper.

func WithPasswordEncoding

func WithPasswordEncoding(encoding *base64.Encoding) option

WithPasswordEnoding sets password encoding to the gophkeeper.

Types

type DSNSource

type DSNSource string

DSNSource is a pgx source from DSN string.

func (DSNSource) Connect

func (dsn DSNSource) Connect(ctx context.Context) (*pgx.Conn, error)

Connect implements DatabaseSource.

type DatabaseSource

type DatabaseSource interface {
	Connect(context.Context) (*pgx.Conn, error)
}

DatabaseSource is a source of pgx connections.

type Gophkeeper

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

Gophkeeper is a postgresql identity repository.

func New

func New(source DatabaseSource, tokenSource server.UsernameBasedTokenSource, options ...option) *Gophkeeper

New craetes a new postgres Gophkeeper and returns it.

func (*Gophkeeper) Authenticate

func (r *Gophkeeper) Authenticate(ctx context.Context, credential gophkeeper.Credential) (gophkeeper.Token, error)

Authenticate implements Repository.

func (*Gophkeeper) Identity

func (r *Gophkeeper) Identity(ctx context.Context, token gophkeeper.Token) (gophkeeper.Identity, error)

Identity implements Repository.

func (*Gophkeeper) Register

func (r *Gophkeeper) Register(ctx context.Context, credential gophkeeper.Credential) error

Register implements Repository.

func (*Gophkeeper) Run

func (r *Gophkeeper) Run(ctx context.Context) error

Run implements Runnable.

type Identity

type Identity struct {
	Connection       *pgx.Conn
	PasswordEncoding *base64.Encoding
	BlobsDir         string

	Username string
}

Identity is a postgres identity.

func (*Identity) Delete

func (i *Identity) Delete(ctx context.Context, rid gophkeeper.ResourceID) error

Delete implements Identity.

func (*Identity) List

func (i *Identity) List(ctx context.Context) ([]gophkeeper.Resource, error)

List implements Identity.

func (*Identity) RestoreBlob

func (i *Identity) RestoreBlob(ctx context.Context, rid gophkeeper.ResourceID, password string) (gophkeeper.Blob, error)

RestoreBlob implements Identity.

func (*Identity) RestorePiece

func (i *Identity) RestorePiece(ctx context.Context, rid gophkeeper.ResourceID, password string) (gophkeeper.Piece, error)

RestorePiece implements Identity.

func (*Identity) StoreBlob

func (i *Identity) StoreBlob(ctx context.Context, blob gophkeeper.Blob, password string) (gophkeeper.ResourceID, error)

StoreBlob implements Identity.

func (*Identity) StorePiece

func (i *Identity) StorePiece(ctx context.Context, piece gophkeeper.Piece, password string) (gophkeeper.ResourceID, error)

StorePiece implements Identity.

Jump to

Keyboard shortcuts

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