Documentation
¶
Index ¶
- Variables
- func HashInviteValue(val string) string
- func HashRoomToken(tok string) string
- func ValidatePassword(password string) error
- func ValidateUsername(username string) error
- type DB
- type ErrorInviteLinkVerify
- type GetUserOptions
- type InviteLink
- type Manager
- func (m *Manager) Close()
- func (m *Manager) GenerateInviteLink(ctx context.Context, label string, creator *User, perms Perms) (InviteLink, error)
- func (m *Manager) GenerateRoomToken(ctx context.Context, label string, creator *User) (string, error)
- func (m *Manager) InviteLinkURL(l InviteLink) string
- func (m *Manager) SetPassword(u *User, password []byte) error
- func (m *Manager) VerifyPassword(u *User, password []byte) bool
- type ManagerOptions
- type PasswordOptions
- type PermKind
- type Perms
- type RoomToken
- type TokenChecker
- type TokenCheckerOptions
- type UpdateUserOptions
- type User
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func HashInviteValue ¶
func HashRoomToken ¶
func ValidatePassword ¶
func ValidateUsername ¶
Types ¶
type DB ¶
type DB interface { CreateUser(ctx context.Context, user User, link InviteLink) error GetUser(ctx context.Context, userID string, o ...GetUserOptions) (User, error) GetUserByUsername(ctx context.Context, username string, o ...GetUserOptions) (User, error) ListUsers(ctx context.Context) ([]User, error) UpdateUser(ctx context.Context, user User, o ...UpdateUserOptions) error HasOwnerUser(ctx context.Context) (bool, error) CreateInviteLink(ctx context.Context, link InviteLink) error GetInviteLink(ctx context.Context, linkHash string, now timeutil.UTCTime) (InviteLink, error) PruneInviteLinks(ctx context.Context, now timeutil.UTCTime) error DeleteInviteLink(ctx context.Context, linkHash string, userID string) error CreateRoomToken(ctx context.Context, token RoomToken) error GetRoomToken(ctx context.Context, hash string) (RoomToken, error) DeleteRoomToken(ctx context.Context, tokenHash string, userID string) error }
type ErrorInviteLinkVerify ¶
type ErrorInviteLinkVerify struct {
// contains filtered or unexported fields
}
func (*ErrorInviteLinkVerify) Error ¶
func (e *ErrorInviteLinkVerify) Error() string
func (*ErrorInviteLinkVerify) Unwrap ¶
func (e *ErrorInviteLinkVerify) Unwrap() error
type GetUserOptions ¶
type InviteLink ¶
type InviteLink struct { Hash string `gorm:"primaryKey"` OwnerUserID *string `gorm:"index"` Label string Value string Perms Perms `gorm:"embedded"` CreatedAt timeutil.UTCTime ExpiresAt timeutil.UTCTime `gorm:"index"` }
func (*InviteLink) GenerateNew ¶
func (l *InviteLink) GenerateNew() error
func (InviteLink) Verify ¶
func (l InviteLink) Verify(creator *User) error
type Manager ¶
type Manager struct { DB // contains filtered or unexported fields }
func NewManager ¶
func (*Manager) GenerateInviteLink ¶
func (*Manager) GenerateRoomToken ¶
func (*Manager) InviteLinkURL ¶
func (m *Manager) InviteLinkURL(l InviteLink) string
type ManagerOptions ¶
type ManagerOptions struct { GCInterval time.Duration `toml:"gc-interval"` LinkPrefix string `toml:"link-prefix"` Password *PasswordOptions `toml:"password"` InviteLinkExpiry time.Duration `toml:"invite-link-expiry"` }
func (ManagerOptions) Clone ¶
func (o ManagerOptions) Clone() ManagerOptions
func (*ManagerOptions) FillDefaults ¶
func (o *ManagerOptions) FillDefaults()
type PasswordOptions ¶
type Perms ¶
type Perms struct { IsOwner bool `gorm:"index"` IsBlocked bool CanInvite bool CanDiscuss bool CanRunContests bool CanHostRooms bool CanAdmin bool }
func BlockedPerms ¶
func BlockedPerms() Perms
func OwnerPerms ¶
func OwnerPerms() Perms
type RoomToken ¶
type RoomToken struct { Hash string `gorm:"primaryKey"` Label string UserID string `gorm:"index"` CreatedAt timeutil.UTCTime }
func (*RoomToken) GenerateNew ¶
type TokenChecker ¶
type TokenChecker struct {
// contains filtered or unexported fields
}
func NewTokenChecker ¶
func NewTokenChecker(o TokenCheckerOptions, db DB) *TokenChecker
func (*TokenChecker) Check ¶
func (t *TokenChecker) Check(srcToken string) error
func (*TokenChecker) Close ¶
func (t *TokenChecker) Close()
type TokenCheckerOptions ¶
type TokenCheckerOptions struct {
CacheExpiryInterval time.Duration `toml:"cache-expiry-interval"`
}
func (TokenCheckerOptions) Clone ¶
func (o TokenCheckerOptions) Clone() TokenCheckerOptions
func (*TokenCheckerOptions) FillDefaults ¶
func (o *TokenCheckerOptions) FillDefaults()
type UpdateUserOptions ¶
type UpdateUserOptions struct {
InvalidatePerms bool
}
type User ¶
type User struct { ID string `gorm:"primaryKey"` Username string `gorm:"index"` InviterID *string `gorm:"index"` PasswordHash []byte PasswordSalt []byte Epoch int Perms Perms `gorm:"embedded"` RoomTokens []RoomToken `gorm:"foreignKey:UserID"` InviteLinks []InviteLink `gorm:"foreignKey:OwnerUserID"` }
func (*User) SetPassword ¶
func (u *User) SetPassword(password []byte, o *PasswordOptions) error
func (*User) VerifyPassword ¶
func (u *User) VerifyPassword(password []byte, o *PasswordOptions) bool
Click to show internal directories.
Click to hide internal directories.