services

package
v0.0.0-...-a5e1e4d Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCertUnautorized = errors.New("user does not have access to this certificate")
View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	GetUserForRequest(ctx context.Context, r *http.Request) (*daos.User, error)
	ValidateOAuthToken(
		ctx context.Context,
		provider string,
		accessToken string,
	) (*daos.User, error)
}

func NewAuthService

func NewAuthService(userRepository repositories.UserRepository) AuthService

type AuthServiceImpl

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

func (*AuthServiceImpl) GetUserForRequest

func (s *AuthServiceImpl) GetUserForRequest(ctx context.Context, r *http.Request) (
	*daos.User,
	error,
)

func (*AuthServiceImpl) ValidateOAuthToken

func (s *AuthServiceImpl) ValidateOAuthToken(
	ctx context.Context,
	provider string,
	accessToken string,
) (*daos.User, error)

type CertInfo

type CertInfo struct {
	Cert       *x509.Certificate
	PrivateKey *rsa.PrivateKey
}

type CertificateService

type CertificateService interface {
	DeleteCertForUser(ctx context.Context, id string, userID string) error
	GetCert(ctx context.Context, id string) (*contracts.CertificateResponse, error)
	GetCertAsPEMForUser(ctx context.Context, id string, userID string) (string, error)
	GetUserCerts(
		ctx context.Context,
		userId string,
		certTypes []CertificateType,
	) ([]*contracts.CertificateLightResponse, error)
	CreateCACert(
		ctx context.Context,
		request *contracts.CreateCARequest,
		userID string,
		certType CertificateType,
	) (
		[]byte,
		error,
	)
	CreateCert(
		ctx context.Context,
		caID string,
		request *contracts.CreateCertificateRequest,
		userID string,
	) (*contracts.CertificateLightResponse, error)
	GetCertsByParentCAForUser(
		ctx context.Context,
		parentCA string,
		userID string,
	) ([]*contracts.CertificateLightResponse, error)
}

type CertificateServiceImpl

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

func NewCertificateServiceImpl

func NewCertificateServiceImpl(
	certRepository repositories.CertRepository,
	keyRepository repositories.KeyRepository,
	keyService KeyService,
) *CertificateServiceImpl

func (*CertificateServiceImpl) CreateCACert

func (c *CertificateServiceImpl) CreateCACert(
	ctx context.Context,
	request *contracts.CreateCARequest,
	userID string,
	certificateType CertificateType,
) ([]byte, error)

func (*CertificateServiceImpl) CreateCert

func (*CertificateServiceImpl) DeleteCertForUser

func (c *CertificateServiceImpl) DeleteCertForUser(
	ctx context.Context,
	id string,
	userID string,
) error

func (*CertificateServiceImpl) GetCert

func (*CertificateServiceImpl) GetCertAsPEMForUser

func (c *CertificateServiceImpl) GetCertAsPEMForUser(
	ctx context.Context,
	id string,
	userID string,
) (string, error)

func (*CertificateServiceImpl) GetCertsByParentCAForUser

func (c *CertificateServiceImpl) GetCertsByParentCAForUser(
	ctx context.Context,
	parentCA string,
	userID string,
) ([]*contracts.CertificateLightResponse, error)

func (*CertificateServiceImpl) GetUserCerts

func (c *CertificateServiceImpl) GetUserCerts(
	ctx context.Context,
	userId string,
	certTypes []CertificateType,
) (
	[]*contracts.CertificateLightResponse,
	error,
)

type CertificateType

type CertificateType string
const (
	CertTypeRootCA         CertificateType = "root_ca"
	CertTypeIntermediateCA CertificateType = "intermediate_ca"
	CertTypeCertificate    CertificateType = "certificate"
)

func (CertificateType) String

func (ct CertificateType) String() string

type KeyService

type KeyService interface {
	CreateKey(
		ctx context.Context,
		userId string,
		name string,
		algorithm contracts.KeyAlgorithm,
		password string,
	) (
		*contracts.KeyLightResponse,
		error,
	)
	GetDecryptedKeyForUser(
		ctx context.Context,
		keyId string,
		userId string,
		password string,
	) (PrivateKey, error)
	GetKeysForUser(
		ctx context.Context,
		userId string,
	) ([]*contracts.KeyLightResponse, error)
}

type KeyServiceImpl

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

func NewKeyServiceImpl

func NewKeyServiceImpl(keyRepository repositories.KeyRepository) *KeyServiceImpl

func (*KeyServiceImpl) CreateKey

func (k *KeyServiceImpl) CreateKey(
	ctx context.Context,
	userId string,
	name string,
	algorithm contracts.KeyAlgorithm,
	password string,
) (*contracts.KeyLightResponse, error)

func (*KeyServiceImpl) GetDecryptedKeyForUser

func (k *KeyServiceImpl) GetDecryptedKeyForUser(
	ctx context.Context,
	keyId string,
	userId string,
	password string,
) (PrivateKey, error)

func (*KeyServiceImpl) GetKeysForUser

func (k *KeyServiceImpl) GetKeysForUser(
	ctx context.Context,
	userId string,
) ([]*contracts.KeyLightResponse, error)

type OAuthClaims

type OAuthClaims struct {
	Email     string
	FirstName string
	LastName  string
}

type PrivateKey

type PrivateKey interface {
	Public() crypto.PublicKey
	Equal(x crypto.PrivateKey) bool
}

PrivateKey is a custom interface - all crypto packages implement this interface, but crypto.PrivateKey type is any for backwards compat

Jump to

Keyboard shortcuts

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