service

package
v0.0.0-...-1f982fd Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPassword = errors.New("invalid login and(or) password")
	ErrUnsupportedType = errors.New("unsupported type")
)

Functions

func BuildJWTString

func BuildJWTString(secretKey, userID string) (string, error)

BuildJWTString generates a JWT token.

func Decrypt

func Decrypt(secretKey string, data []byte) ([]byte, error)

Decrypt decrypts the encrypted data and returns it as a byte slice.

func Encrypt

func Encrypt(secretKey string, data []byte) ([]byte, error)

Encrypt encrypts data and returns it as a byte slice.

Types

type Claims

type Claims struct {
	jwt.RegisteredClaims
	UserID string
}

Claims represents the claims for a JWT token.

type Service

type Service struct {
	Storage  StoreI
	S3Client s3.S3ClientI
	Cfg      *config.Config
}

func (*Service) AuthUser

func (s *Service) AuthUser(ctx context.Context, in model.UserCredentials) (string, error)

func (*Service) GetData

func (s *Service) GetData(ctx context.Context, id string) (*pb.GetResponse, error)

func (*Service) GetUserData

func (s *Service) GetUserData(ctx context.Context) (*pb.GetManyResponse, error)

GetUserData retrieves all user data. The method could be used for synchronize purposes.

func (*Service) GetUserID

func (s *Service) GetUserID(tokenString, secretKey string) string

GetUserID retrieves a userID string from the passed JWT token.

func (*Service) RegisterUser

func (s *Service) RegisterUser(ctx context.Context, in model.UserCredentials) (string, error)

RegisterUser encrypts password, saves user login and password into database.

func (*Service) SaveData

func (s *Service) SaveData(ctx context.Context, in *pb.SaveRequest) (string, error)

SaveData encrypts and saves user data.

func (*Service) SaveMeta

func (s *Service) SaveMeta(ctx context.Context, metadata model.Save) (string, error)

SaveMeta saves metadata into db.

type StoreI

type StoreI interface {
	Register(ctx context.Context, in model.UserCredentials) (model.UserID, error)
	GetUser(ctx context.Context, login string) (*storage.UserEntity, error)
	Save(ctx context.Context, data model.Save) (string, error)
	Get(ctx context.Context, id string) (*storage.MetadataEntity, error)
	GetMany(ctx context.Context) ([]*storage.MetadataEntity, error)
}

Directories

Path Synopsis
Package svcmock is a generated GoMock package.
Package svcmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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