auth

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0, MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth is Skiff's accounts + teams layer: users belong to teams, and projects/env/deploys are scoped to a team. 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

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)

func (*Store) CreateUserNoTeam

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

CreateUserNoTeam adds a user without a personal team, for the invite flow where they join the inviter's team instead.

func (*Store) DeleteTeam

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

DeleteTeam removes a team with its memberships and invites; callers must first ensure it owns no apps or databases.

func (*Store) DeleteUser

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

DeleteUser removes a user and their 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

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

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