Documentation ¶
Index ¶
- Variables
- func CheckShortURL(p *Paste) error
- func Close()
- func GetConfigPath() string
- func GetDBPath() string
- func GetPastesDir() string
- func HashExist(hash any) bool
- func Init() (err error)
- func InitWebAuthn() (err error)
- func LoadConfig()
- func PostInit()
- func RenameOldDatabaseColumn()
- func ResetAdmin()
- func ResetHoldCount() error
- func SaveConfig()
- func ShortURLExist(name string) bool
- func UserDiscoverableHandle(rawID, userHandle []byte) (webauthn.User, error)
- func UserDiscoverableLoginRequest() (assertion *protocol.CredentialAssertion, session *webauthn.SessionData, ...)
- type Paste
- func QueryAllPaste(page int64, page_size int64) (pastes []*Paste, total int, err error)
- func QueryAllPasteByUser(uid int64, page int64, page_size int64) (pastes []*Paste, total int, err error)
- func QueryPasteByHash(hash Paste_Hash) (*Paste, error)
- func QueryPasteByShortURLOrHash(name string) (p *Paste, err error)
- func QueryPasteByUUID(uuid string) (*Paste, error)
- func (p *Paste) Access(hold_before time.Time) error
- func (p *Paste) Base64Hash() string
- func (p *Paste) CreateShortURL() error
- func (p *Paste) Delete() error
- func (p *Paste) FlagDelete() error
- func (p *Paste) ForceDelete() error
- func (p *Paste) GenerateShortURL() error
- func (p *Paste) HexHash() string
- func (p *Paste) Hold() error
- func (p *Paste) Path() string
- func (p *Paste) Save() (*Paste, error)
- func (p *Paste) SetPassword(password string) (err error)
- func (p *Paste) Token(ExpireAfter time.Time) string
- func (p *Paste) Unhold() error
- func (p *Paste) Update() (paste *Paste, err error)
- func (p *Paste) UpdateMetadata() error
- func (p *Paste) UpdateShortURL() error
- func (p *Paste) User() (*User, error)
- func (p *Paste) Valid() bool
- func (p *Paste) VerifyToken(token string) bool
- type Paste_Extra
- type Paste_Hash
- type Pastebin_Config
- type Pastebin_DB
- type Session
- type User
- func (user *User) ChangePassword(oldPassword string, newPassword string) error
- func (user *User) Create(setuid bool) (err error)
- func (user *User) Delete() error
- func (user *User) IsAdmin() bool
- func (user *User) IsAnonymous() bool
- func (user *User) LoginWebAuthn(c echo.Context, session webauthn.SessionData) error
- func (user *User) LoginWebAuthnRequest() (assertion *protocol.CredentialAssertion, session *webauthn.SessionData, ...)
- func (user *User) RegisterWebAuthn(c echo.Context, session webauthn.SessionData, credential_name string, ...) error
- func (user *User) RegisterWebAuthnRequest(credential_name string, passkey bool) (creation *protocol.CredentialCreation, session *webauthn.SessionData, ...)
- func (user *User) RemoveWebAuthnCredential(credential_name string) error
- func (user *User) SetPassword(password string) error
- func (u *User) Token() string
- func (user *User) Update() error
- func (user *User) WebAuthnCredentials() []webauthn.Credential
- func (user *User) WebAuthnDisplayName() string
- func (user *User) WebAuthnID() []byte
- func (user *User) WebAuthnName() string
- type User_Extra
- type User_WebAuthn
- type User_WebAuthn_Credential
Constants ¶
This section is empty.
Variables ¶
View Source
var HTMLTAGRegex = regexp.MustCompile(`(?i)<[^>]*>`)
View Source
var ReservedURL = regexp.MustCompile(`^(sw\.js(\.map)?|workbox.*?\.js(\.map)?|manifest\.json|favicon\.ico|robots\.txt|index\.(x|s)?htm(l)?|admin\.(x|s)?htm(l)?)$`)
View Source
var ShortURLRule = regexp.MustCompile(`^[a-zA-Z0-9_\.-]+$`)
Functions ¶
func Close ¶
func Close()
func LoadConfig ¶
func LoadConfig()
func PostInit ¶
func PostInit()
func RenameOldDatabaseColumn ¶
func RenameOldDatabaseColumn()
func ResetAdmin ¶
func ResetAdmin()
func SaveConfig ¶
func SaveConfig()
func UserDiscoverableHandle ¶
func UserDiscoverableLoginRequest ¶
func UserDiscoverableLoginRequest() (assertion *protocol.CredentialAssertion, session *webauthn.SessionData, err error)
Types ¶
type Paste ¶
type Paste struct { UUID string `db:"uuid"` UID int64 `db:"uid"` Content io.Reader `db:"-"` Hash Paste_Hash `db:"hash"` Password string `db:"password"` ExpireAfter time.Time `db:"expire_after"` AccessCount int64 `db:"access_count"` MaxAccessCount int64 `db:"max_access_count"` DeleteIfNotAvailable bool `db:"delete_if_not_available"` HoldCount int64 `db:"hold_count"` HoldBefore time.Time `db:"hold_before"` Extra *Paste_Extra `db:"extra"` CreatedAt time.Time `db:"created_at"` Short_url string `db:"short_url"` }
func QueryAllPaste ¶
func QueryAllPasteByUser ¶
func QueryPasteByHash ¶
func QueryPasteByHash(hash Paste_Hash) (*Paste, error)
func QueryPasteByShortURLOrHash ¶
type Paste_Extra ¶
type Paste_Extra struct { MimeType string `json:"mime_type"` FileName string `json:"filename"` Size uint64 `json:"size"` HashPadding bool `json:"hash_padding"` }
func (*Paste_Extra) Scan ¶
func (e *Paste_Extra) Scan(src any) error
func (*Paste_Extra) String ¶
func (e *Paste_Extra) String() string
func (*Paste_Extra) Value ¶
func (e *Paste_Extra) Value() (driver.Value, error)
type Paste_Hash ¶
type Paste_Hash int64
func DecodeBase64Hash ¶
func DecodeBase64Hash(base64_hash string) (Paste_Hash, error)
type Pastebin_Config ¶
type Pastebin_Config struct { SiteName string `yaml:"site_name"` SiteTitle string `yaml:"site_title"` SiteDomain string `yaml:"site_domain"` WebauthnOrigins []string `yaml:"webauthn_origins"` SupportNoFilename bool `yaml:"support_no_filename"` Mode string `yaml:"mode"` AllowHTML bool `yaml:"allow_html"` AllowAnonymous bool `yaml:"allow_anonymous"` UserCookieMaxAge int `yaml:"user_cookie_max_age"` PasteAssessTokenAge int `yaml:"paste_assess_token_age"` CustomTemplateDir string `yaml:"custom_template_dir"` SessionCookie string `yaml:"session_cookie"` DefaultColorScheme string `yaml:"default_color_scheme"` // contains filtered or unexported fields }
var Config *Pastebin_Config = &Pastebin_Config{ SiteName: "Pastebin", SiteTitle: "", SiteDomain: "go-pastebin.app", WebauthnOrigins: []string{"https://go-pastebin.app"}, Mode: "release", SupportNoFilename: true, AllowHTML: false, AllowAnonymous: true, UserCookieMaxAge: 86400 * 30, PasteAssessTokenAge: 86400, DefaultColorScheme: "light", SessionCookie: "PASTEBIN_SESSION", CustomTemplateDir: "", dataDir: flag.String("data", "/var/lib/go-pastebin", "Data directory"), webauthnConfig: &webauthn.Config{}, }
type User ¶
type User struct { UID int64 `json:"uid" db:"uid"` Username string `json:"username" db:"username"` Email string `json:"email" db:"email"` Role string `json:"role" db:"role"` Password string `json:"-" db:"password"` Extra *User_Extra `json:"extra" db:"extra"` }
func UserDiscoverableLogin ¶
func UserDiscoverableLogin(c echo.Context, session webauthn.SessionData) (*User, error)
func (*User) ChangePassword ¶
func (*User) LoginWebAuthn ¶
func (user *User) LoginWebAuthn(c echo.Context, session webauthn.SessionData) error
func (*User) LoginWebAuthnRequest ¶
func (user *User) LoginWebAuthnRequest() (assertion *protocol.CredentialAssertion, session *webauthn.SessionData, err error)
func (*User) RegisterWebAuthn ¶
func (*User) RegisterWebAuthnRequest ¶
func (user *User) RegisterWebAuthnRequest(credential_name string, passkey bool) (creation *protocol.CredentialCreation, session *webauthn.SessionData, err error)
func (*User) RemoveWebAuthnCredential ¶
func (*User) WebAuthnCredentials ¶
func (user *User) WebAuthnCredentials() []webauthn.Credential
type User_Extra ¶
type User_Extra struct {
WebAuthn *User_WebAuthn `json:"webauthn"`
}
func (*User_Extra) Scan ¶
func (e *User_Extra) Scan(src any) error
func (*User_Extra) String ¶
func (e *User_Extra) String() string
func (*User_Extra) Value ¶
func (e *User_Extra) Value() (driver.Value, error)
type User_WebAuthn ¶
type User_WebAuthn struct { Id []byte `json:"id"` Credentials map[string]*User_WebAuthn_Credential `json:"credential"` }
Click to show internal directories.
Click to hide internal directories.