mirror of
https://github.com/go-shiori/shiori.git
synced 2025-09-08 14:05:54 +08:00
* feat: Add SSO forward header * fix: Use domain layer * test: Some test * chore: Print new values when debugging * chore: Rename enabled envvar * fix: Wrongly parsing remote ip * fix: Always validate token. NPE on validateSession * fix: Dont overwrite token when sso * fix: Best effort to get ip. Parse as ip:port and then as ip * fix: Forgot to update handler version * fix: Forgot to commit changes * test: GetAccountByUsername * chore: Rename some variables * chore: return error from ssoAccount * refactor: Extract sso proxy auth to own middleware * fix: Dont panic if not sso account on legacy validate session * ci: gofmt --------- Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
61 lines
2.2 KiB
Go
61 lines
2.2 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"io/fs"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/go-shiori/warc"
|
|
"github.com/spf13/afero"
|
|
)
|
|
|
|
type BookmarksDomain interface {
|
|
HasEbook(b *BookmarkDTO) bool
|
|
HasArchive(b *BookmarkDTO) bool
|
|
HasThumbnail(b *BookmarkDTO) bool
|
|
GetBookmark(ctx context.Context, id DBID) (*BookmarkDTO, error)
|
|
GetBookmarks(ctx context.Context, ids []int) ([]BookmarkDTO, error)
|
|
UpdateBookmarkCache(ctx context.Context, bookmark BookmarkDTO, keepMetadata bool, skipExist bool) (*BookmarkDTO, error)
|
|
BulkUpdateBookmarkTags(ctx context.Context, bookmarkIDs []int, tagIDs []int) error
|
|
AddTagToBookmark(ctx context.Context, bookmarkID int, tagID int) error
|
|
RemoveTagFromBookmark(ctx context.Context, bookmarkID int, tagID int) error
|
|
BookmarkExists(ctx context.Context, id int) (bool, error)
|
|
}
|
|
|
|
type AuthDomain interface {
|
|
CheckToken(ctx context.Context, userJWT string) (*AccountDTO, error)
|
|
GetAccountFromCredentials(ctx context.Context, username, password string) (*AccountDTO, error)
|
|
CreateTokenForAccount(account *AccountDTO, expiration time.Time) (string, error)
|
|
}
|
|
|
|
type AccountsDomain interface {
|
|
ListAccounts(ctx context.Context) ([]AccountDTO, error)
|
|
GetAccountByUsername(ctx context.Context, username string) (*AccountDTO, error)
|
|
CreateAccount(ctx context.Context, account AccountDTO) (*AccountDTO, error)
|
|
UpdateAccount(ctx context.Context, account AccountDTO) (*AccountDTO, error)
|
|
DeleteAccount(ctx context.Context, id int) error
|
|
}
|
|
|
|
type ArchiverDomain interface {
|
|
DownloadBookmarkArchive(book BookmarkDTO) (*BookmarkDTO, error)
|
|
GetBookmarkArchive(book *BookmarkDTO) (*warc.Archive, error)
|
|
}
|
|
|
|
type StorageDomain interface {
|
|
Stat(name string) (fs.FileInfo, error)
|
|
FS() afero.Fs
|
|
FileExists(path string) bool
|
|
DirExists(path string) bool
|
|
WriteData(dst string, data []byte) error
|
|
WriteFile(dst string, src *os.File) error
|
|
}
|
|
|
|
type TagsDomain interface {
|
|
ListTags(ctx context.Context, opts ListTagsOptions) ([]TagDTO, error)
|
|
CreateTag(ctx context.Context, tag TagDTO) (TagDTO, error)
|
|
GetTag(ctx context.Context, id int) (TagDTO, error)
|
|
UpdateTag(ctx context.Context, tag TagDTO) (TagDTO, error)
|
|
DeleteTag(ctx context.Context, id int) error
|
|
TagExists(ctx context.Context, id int) (bool, error)
|
|
}
|