Documentation ¶
Index ¶
- Variables
- func CookieValue(passwordHash, userIP string) string
- func GetOriginalIP(r *http.Request) string
- func Hash(s string) string
- func ImageRating(rating string) string
- func NewContextWithUser(ctx context.Context, user *User) context.Context
- func PasswordHash(username, password string) string
- func SetCookie(w http.ResponseWriter, name, value string)
- type Alias
- type Autocomplete
- type Common
- type ContributedTagHistory
- type Image
- type PM
- type PMChoice
- type RatedImage
- type SCoreLog
- type Schemer
- type Shimmie
- type Tag
- type TagHistory
- type User
- type UserGetter
- type UserScore
Constants ¶
This section is empty.
Variables ¶
var ( ErrWrongCredentials = errors.New("wrong username or password") ErrNotFound = errors.New("entry not found") )
Errors returned by Verify.
Functions ¶
func CookieValue ¶
CookieValue recreates the Shimmie session cookie value based on the user password hash and the user IP.
Shimmie creates a cookie "shm_session" containing an md5 digest value of the user password hash concatenated with the user IP masked with the 255.255.0.0 mask. That's essentially:
md5(password_hash + masked_ip)
func GetOriginalIP ¶
GetOriginalIP gets the original IP of the HTTP for the case of being behind a proxy. It searches for the X-Forwarded-For header.
func ImageRating ¶
ImageRating converts rating letters to full words.
s -> Safe q -> Questionable e -> Explicit
If another value except (s, q, e) is given, then it returns that value as it is.
func NewContextWithUser ¶
NewContextWithUser adds user to context.
func PasswordHash ¶
PasswordHash returns the password hash of a username and password the same way that shimmie2 does it.
func SetCookie ¶
func SetCookie(w http.ResponseWriter, name, value string)
SetCookie creates a cookie on path "/" with 1 year expiration and other flags set to false mimicking the cookies that Shimmie creates.
Types ¶
type Autocomplete ¶
type Autocomplete struct { Old string `json:"old"` Name string `json:"name"` Count int `json:"count"` }
Autocomplete is the result of searching into tags and tag alias to give autocomplete suggestions.
type ContributedTagHistory ¶
type ContributedTagHistory struct { ID int ImageID int OwnerID int OwnerName string TaggerID int TaggerName string TaggerIP string Tags string DateSet *time.Time }
ContributedTagHistory holds previous tags for an image that were set by contributors.
type Image ¶
type Image struct { ID int64 OwnerID int64 OwnerIP string Filename string Filesize int Hash string Ext string Source string Width int Height int Posted *time.Time Locked string NumericScore int Rating string Favorites int ParentID int64 HasChildren bool Author string Notes int }
Image represents a shimmie image.
type PM ¶ added in v0.2.0
type PM struct { FromUser string `json:"from_user"` ToUser string `json:"to_user"` ID int64 `json:"id"` FromID int64 `json:"from_id"` FromIP string `json:"from_ip"` ToID int64 `json:"to_id"` SentDate time.Time `json:"sent_date"` Subject string `json:"subject"` Message string `json:"message"` IsRead bool `json:"is_read"` }
PM is a private message exchanged between users.
type PMChoice ¶ added in v0.2.0
type PMChoice int
PMChoice allows to choose between read and unread private messages.
type RatedImage ¶
RatedImage represents a shimmie image that also carries information about who rated it and when.
func (RatedImage) RateDateFormat ¶
func (ri RatedImage) RateDateFormat() string
RateDateFormat returns the RateDate as UTC with Mon 02 Jan 2006 15:04:05 MST format.
type SCoreLog ¶
type SCoreLog struct { ID int64 DateSent *time.Time Section string Username string Address string Priority int Message string }
SCoreLog represents a log message in the shimmie log that is stored in the table "score_log".
type Schemer ¶
Schemer describes operations that can be done on the database schema. Those operations include creating and dropping the schema for a specific database name.
type Shimmie ¶
type Shimmie struct { ImagePath string ThumbPath string User UserGetter }
Shimmie represents an installed shimmie2 project.
func (*Shimmie) Auth ¶
Auth is a handler wrapper that checks if a user is authenticated to Shimmie. It checks for two cookies "shm_user" and "shm_session". The first contains the username which is used to query the database and the get user's password hash. Then it attempts to recreate the "shm_session" cookie value by using the username, user IP and password hash. If the recreated value does not match the "shm_session" cookie value then it redirects to redirectPath. If redirectURL is empty then "/user_admin/login" is used instead which is the default login URL for Shimmie.
type TagHistory ¶
type TagHistory struct { ID int64 ImageID int64 UserID int64 UserIP string Tags string DateSet *time.Time // Name of the user who did the edit. Name string }
TagHistory holds previous tags for an image.
type User ¶
type User struct { ID int64 Name string Pass string JoinDate *time.Time Admin string Email string Class string }
User represents a shimmie user.
type UserGetter ¶ added in v0.4.0
UserGetter represents a type that can get users from the db.
type UserScore ¶ added in v0.3.0
type UserScore struct { Score int `json:"score"` ID int64 `json:"id"` Name string `json:"name"` JoinDate *time.Time `json:"join_date"` Email string `json:"email"` Class string `json:"class"` }
UserScore can be used to hold user scores like who has uploaded the most images and who has edited the most tags.