certificate

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenHeaderType = "JWT"
)

Variables

View Source
var (
	TokenAlgorithm = jwt.SigningMethodES256
)

Functions

func ParsePKCS8PrivateKey

func ParsePKCS8PrivateKey(b64 string) (*ecdsa.PrivateKey, error)

Types

type CertificateApplication

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

func NewCertificateApplication

func NewCertificateApplication(repo CertificateRepository, srv CertificateService, logger *zap.Logger) *CertificateApplication

func (*CertificateApplication) CreateFileAccessCertificate

func (app *CertificateApplication) CreateFileAccessCertificate(ctx context.Context, uid int32, file File) (*FileAccessCertificate, error)

func (*CertificateApplication) GetFileAccessCertificate

func (app *CertificateApplication) GetFileAccessCertificate(ctx context.Context, uid int32, fid string) (*FileAccessCertificate, error)

type CertificateGrpcService

type CertificateGrpcService struct {
	proto.UnimplementedCertificateServiceServer
	// contains filtered or unexported fields
}

func NewCertificateGrpcServer

func NewCertificateGrpcServer(app *CertificateApplication, logger *zap.Logger, authHeader string) *CertificateGrpcService

func (*CertificateGrpcService) Get

type CertificateRepository

type CertificateRepository interface {
	Create(ctx context.Context, cert *FileAccessCertificate) error
	FindByFileIdAndUserId(ctx context.Context, userId int32, fileId string) (*FileAccessCertificate, error)
	Save(ctx context.Context, cert *FileAccessCertificate) error
	Delete(ctx context.Context, cert *FileAccessCertificate) error
}

type CertificateService

type CertificateService interface {
	SignFileAccessCertificate(cert *FileAccessCertificate) error
}

type File

type File interface {
	Permission(uid int32) Permission
	Id() string
}

type FileAccessCertificate

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

func NewFileAccessCertificate

func NewFileAccessCertificate(uid int32, file File) *FileAccessCertificate

func (*FileAccessCertificate) Claims

func (cert *FileAccessCertificate) Claims(ttl *time.Duration, issuer string) (*FileAccessClaims, error)

func (*FileAccessCertificate) Token

func (cert *FileAccessCertificate) Token() string

type FileAccessClaims

type FileAccessClaims struct {
	jwt.RegisteredClaims `json:",inline"`
	FileId               string `json:"file_id"`
	Read                 bool   `json:"can_read"`
	Write                bool   `json:"can_write"`
	Owner                bool   `json:"is_owner"`
}

func (*FileAccessClaims) Permission

func (claims *FileAccessClaims) Permission() (perms Permission)

type JWTCertificateService

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

func NewCertificateService

func NewCertificateService(sign *ecdsa.PrivateKey, issuer string, ttl *time.Duration, logger *zap.Logger) *JWTCertificateService

func (*JWTCertificateService) ParseFileAccessCertificate

func (service *JWTCertificateService) ParseFileAccessCertificate(tokenStr string) (*FileAccessCertificate, error)

func (*JWTCertificateService) SignFileAccessCertificate

func (service *JWTCertificateService) SignFileAccessCertificate(cert *FileAccessCertificate) error

type MongoCertificateRepository

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

func NewMongoCertificateRepository

func NewMongoCertificateRepository(db *mongo.Database, logger *zap.Logger) *MongoCertificateRepository

func (*MongoCertificateRepository) Create

func (*MongoCertificateRepository) Delete

func (*MongoCertificateRepository) DeleteAllByFileId

func (repo *MongoCertificateRepository) DeleteAllByFileId(ctx context.Context, fileId string) error

func (*MongoCertificateRepository) DeleteByFileIdAndUserId

func (repo *MongoCertificateRepository) DeleteByFileIdAndUserId(ctx context.Context, userId int32, fileId string) error

func (*MongoCertificateRepository) FindByFileIdAndUserId

func (repo *MongoCertificateRepository) FindByFileIdAndUserId(ctx context.Context, userId int32, fileId string) (*FileAccessCertificate, error)

func (*MongoCertificateRepository) Save

type Permission

type Permission uint8
const (
	Read  Permission = 0x01
	Write Permission = 0x02
	Owner Permission = 0x04
)

Jump to

Keyboard shortcuts

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