auth

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package auth is Skiff's accounts + teams layer: users authenticate, belong to teams, and everything else (projects, env, deploys) is scoped to a team. It's a self-hosted, single-instance model — teams organize collaborators on your own box, not a central SaaS. Backed by SQLite.

Index

Constants

View Source
const (
	RoleOwner  = "owner"
	RoleMember = "member"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Invite

type Invite struct {
	Token   string `json:"token"`
	Email   string `json:"email"`
	TeamID  string `json:"teamId"`
	Role    string `json:"role"`
	Created int64  `json:"created"`
}

type Member

type Member struct {
	User User   `json:"user"`
	Role string `json:"role"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(db *sql.DB) *Store

func (*Store) AcceptInvite

func (s *Store) AcceptInvite(token, userID string) (Team, error)

func (*Store) Authenticate

func (s *Store) Authenticate(email, password string) (User, bool)

func (*Store) ChangePassword

func (s *Store) ChangePassword(userID, current, next string) error

ChangePassword verifies the current password, then sets a new one.

func (*Store) CreateInvite

func (s *Store) CreateInvite(email, teamID, role string) (Invite, error)

func (*Store) CreateTeam

func (s *Store) CreateTeam(name, ownerID string) (Team, error)

func (*Store) CreateUser

func (s *Store) CreateUser(email, name, password string) (User, Team, error)

CreateUser adds a user with a bcrypt-hashed password and a personal team.

func (*Store) CreateUserNoTeam

func (s *Store) CreateUserNoTeam(email, name, password string) (User, error)

CreateUserNoTeam adds a user with no personal team — used when accepting an invite, where the user joins the inviter's team rather than getting one of their own.

func (*Store) DeleteTeam

func (s *Store) DeleteTeam(teamID string) error

DeleteTeam removes a team along with its memberships and pending invites. Callers must first ensure the team owns no apps or databases.

func (*Store) DeleteUser

func (s *Store) DeleteUser(userID string) error

DeleteUser removes a user and all their team memberships. Callers must first deal with any teams the user solely owns.

func (*Store) HasUsers

func (s *Store) HasUsers() bool

func (*Store) Invite

func (s *Store) Invite(token string) (Invite, bool)

func (*Store) LeaveTeam

func (s *Store) LeaveTeam(userID, teamID string) error

LeaveTeam drops the caller's own membership, refusing if they're the last owner.

func (*Store) Members

func (s *Store) Members(teamID string) []Member

func (*Store) RemoveMember

func (s *Store) RemoveMember(teamID, userID string) error

RemoveMember drops a user from a team, refusing to remove the last owner.

func (*Store) RenameTeam

func (s *Store) RenameTeam(teamID, name string) error

RenameTeam changes a team's name (and slug).

func (*Store) Role

func (s *Store) Role(userID, teamID string) (string, bool)

func (*Store) TeamsForUser

func (s *Store) TeamsForUser(userID string) []Team

func (*Store) UpdateName

func (s *Store) UpdateName(userID, name string) error

UpdateName changes a user's display name.

func (*Store) User

func (s *Store) User(userID string) (User, bool)

func (*Store) UserByEmail

func (s *Store) UserByEmail(email string) (User, bool)

type Team

type Team struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Slug    string `json:"slug"`
	Created int64  `json:"created"`
}

type User

type User struct {
	ID           string `json:"id"`
	Email        string `json:"email"`
	Name         string `json:"name"`
	PasswordHash string `json:"passwordHash,omitempty"`
	Created      int64  `json:"created"`
}

Jump to

Keyboard shortcuts

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