Documentation ¶
Index ¶
- Constants
- Variables
- func ParsePKCS8PrivateKey(b64 string) (*ecdsa.PrivateKey, error)
- type CertificateApplication
- type CertificateGrpcService
- type CertificateRepository
- type CertificateService
- type File
- type FileAccessCertificate
- type FileAccessClaims
- type JWTCertificateService
- type MongoCertificateRepository
- func (repo *MongoCertificateRepository) Create(ctx context.Context, cert *FileAccessCertificate) error
- func (repo *MongoCertificateRepository) Delete(ctx context.Context, cert *FileAccessCertificate) error
- func (repo *MongoCertificateRepository) DeleteAllByFileId(ctx context.Context, fileId string) error
- func (repo *MongoCertificateRepository) DeleteByFileIdAndUserId(ctx context.Context, userId int32, fileId string) error
- func (repo *MongoCertificateRepository) FindByFileIdAndUserId(ctx context.Context, userId int32, fileId string) (*FileAccessCertificate, error)
- func (repo *MongoCertificateRepository) Save(ctx context.Context, cert *FileAccessCertificate) error
- type Permission
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 ¶
func (server *CertificateGrpcService) Get(ctx context.Context, req *proto.File) (*proto.Certificate, error)
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 (repo *MongoCertificateRepository) Create(ctx context.Context, cert *FileAccessCertificate) error
func (*MongoCertificateRepository) Delete ¶
func (repo *MongoCertificateRepository) Delete(ctx context.Context, cert *FileAccessCertificate) error
func (*MongoCertificateRepository) DeleteAllByFileId ¶
func (repo *MongoCertificateRepository) DeleteAllByFileId(ctx context.Context, fileId string) error
func (*MongoCertificateRepository) DeleteByFileIdAndUserId ¶
func (*MongoCertificateRepository) FindByFileIdAndUserId ¶
func (repo *MongoCertificateRepository) FindByFileIdAndUserId(ctx context.Context, userId int32, fileId string) (*FileAccessCertificate, error)
func (*MongoCertificateRepository) Save ¶
func (repo *MongoCertificateRepository) Save(ctx context.Context, cert *FileAccessCertificate) error
type Permission ¶
type Permission uint8
const ( Read Permission = 0x01 Write Permission = 0x02 Owner Permission = 0x04 )
Click to show internal directories.
Click to hide internal directories.