40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models"
|
|
auditmodels "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/audit"
|
|
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Database interface {
|
|
AuthStorage
|
|
}
|
|
|
|
type AuthStorage interface {
|
|
AddUser(ctx context.Context, id uuid.UUID, login string, username string, passwordHash []byte) error
|
|
GetUserByLogin(ctx context.Context, login string) (*models.User, error)
|
|
GetUserByID(ctx context.Context, id uuid.UUID) (*models.User, error)
|
|
|
|
AddSession(ctx context.Context, ses *models.Session) (uuid.UUID, error)
|
|
GetSession(ctx context.Context, sessionToken string) (*models.Session, error)
|
|
RemoveSession(ctx context.Context, id uuid.UUID) error
|
|
}
|
|
|
|
type AuthAuditLogStorage interface {
|
|
AddEntry(ctx context.Context, entry auditmodels.AuditLogEntry) error
|
|
}
|
|
|
|
type MetaStorage interface {
|
|
SaveMetadata(ctx context.Context, meta files.FileMetadata) (uuid.UUID, error)
|
|
}
|
|
|
|
type BlobStorage interface {
|
|
GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
|
|
SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
|
|
DeleteFile(ctx context.Context, id uuid.UUID) error
|
|
}
|