auth

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthFailed = errors.New("authentication failed")

Functions

func CanClone

func CanClone(caps string) bool

func CanPull

func CanPull(caps string) bool

func CanPush

func CanPush(caps string) bool

func CanPushUV

func CanPushUV(caps string) bool

func CanSyncPrivate

func CanSyncPrivate(caps string) bool

func CreateUser

func CreateUser(d *db.DB, projectCode, login, password, caps string) error

CreateUser inserts a new user into the user table. Panics if d is nil or login is empty.

func DeleteUser

func DeleteUser(d *db.DB, login string) error

DeleteUser deletes a user by login. Returns an error if the user is not found (0 rows affected). Panics if d is nil.

func HasCapability

func HasCapability(caps string, required byte) bool

func SetPassword

func SetPassword(d *db.DB, projectCode, login, password string) error

SetPassword updates the password for a user. Returns an error if the user is not found (0 rows affected). Panics if d is nil.

func UpdateCaps

func UpdateCaps(d *db.DB, login, caps string) error

UpdateCaps updates the capabilities for a user. Returns an error if the user is not found (0 rows affected). Panics if d is nil.

Types

type InviteToken

type InviteToken struct {
	URL      string `json:"url"`
	Login    string `json:"login"`
	Password string `json:"password"`
	Caps     string `json:"caps"`
}

func DecodeInviteToken

func DecodeInviteToken(s string) (InviteToken, error)

func (InviteToken) Encode

func (t InviteToken) Encode() string

type User

type User struct {
	UID     int
	Login   string
	Cap     string
	CExpire time.Time // zero value = no expiry
	Info    string
	MTime   time.Time
}

func GetUser

func GetUser(d *db.DB, login string) (User, error)

GetUser retrieves a user by login. Returns an error if the user is not found. Panics if d is nil.

func ListUsers

func ListUsers(d *db.DB) ([]User, error)

ListUsers returns all users ordered by login. Panics if d is nil.

func VerifyLogin

func VerifyLogin(d *db.DB, projectCode string, card *xfer.LoginCard) (User, error)

VerifyLogin validates a login card against the user table. The server does NOT need the raw payload — the nonce is in card.Nonce. Returns the authenticated User on success, or ErrAuthFailed on any failure. Panics if d or card is nil (TigerStyle preconditions).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL