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
- Variables
- func CodeAt(secret string, t time.Time) string
- func NewTOTPSecret() string
- func TOTPURI(issuer, account, secret string) string
- type Invite
- type Member
- type Store
- func (s *Store) AcceptInvite(token, userID string) (Team, error)
- func (s *Store) Authenticate(email, password string) (User, bool)
- func (s *Store) BeginTwoFactor(userID string) (string, error)
- func (s *Store) ChangePassword(userID, current, next string) error
- func (s *Store) CheckSecondFactor(userID, code string) bool
- func (s *Store) CreateInvite(email, teamID, role string) (Invite, error)
- func (s *Store) CreateTeam(name, ownerID string) (Team, error)
- func (s *Store) CreateUser(email, name, password string) (User, Team, error)
- func (s *Store) CreateUserNoTeam(email, name, password string) (User, error)
- func (s *Store) DeleteTeam(teamID string) error
- func (s *Store) DeleteUser(userID string) error
- func (s *Store) DisableTwoFactor(userID string) error
- func (s *Store) EnableTwoFactor(userID, code string) ([]string, error)
- func (s *Store) HasTwoFactor(userID string) bool
- func (s *Store) HasUsers() bool
- func (s *Store) Invite(token string) (Invite, bool)
- func (s *Store) LeaveTeam(userID, teamID string) error
- func (s *Store) Members(teamID string) []Member
- func (s *Store) RecoveryLeft(userID string) int
- func (s *Store) RegenerateRecovery(userID string) ([]string, error)
- func (s *Store) RemoveMember(teamID, userID string) error
- func (s *Store) RenameTeam(teamID, name string) error
- func (s *Store) Role(userID, teamID string) (string, bool)
- func (s *Store) TeamsForUser(userID string) []Team
- func (s *Store) UpdateName(userID, name string) error
- func (s *Store) User(userID string) (User, bool)
- func (s *Store) UserByEmail(email string) (User, bool)
- type Team
- type User
Constants ¶
const ( RoleOwner = "owner" RoleMember = "member" )
Variables ¶
var ErrBadCode = errors.New("that code didn't match — try the newest one from your app")
Functions ¶
func NewTOTPSecret ¶ added in v0.5.0
func NewTOTPSecret() string
NewTOTPSecret makes a 160-bit secret, base32 as authenticator apps expect.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) BeginTwoFactor ¶ added in v0.5.0
BeginTwoFactor stores a fresh secret that only takes effect once a code from it is confirmed.
func (*Store) ChangePassword ¶
func (*Store) CheckSecondFactor ¶ added in v0.5.0
CheckSecondFactor accepts a current authenticator code, each at most once, or an unused recovery code, which is then spent.
func (*Store) CreateInvite ¶
func (*Store) CreateUser ¶
func (*Store) CreateUserNoTeam ¶
CreateUserNoTeam adds a user without a personal team, for the invite flow where they join the inviter's team instead.
func (*Store) DeleteTeam ¶
DeleteTeam removes a team with its memberships and invites; callers must first ensure it owns no apps or databases.
func (*Store) DeleteUser ¶
DeleteUser removes a user and their memberships; callers must first deal with any teams the user solely owns.
func (*Store) DisableTwoFactor ¶ added in v0.5.0
DisableTwoFactor turns the second step off and drops the recovery codes.
func (*Store) EnableTwoFactor ¶ added in v0.5.0
EnableTwoFactor confirms the pending secret with a code from it and returns new recovery codes.
func (*Store) HasTwoFactor ¶ added in v0.5.0
HasTwoFactor reports whether signing in also needs a code.
func (*Store) LeaveTeam ¶
LeaveTeam drops the caller's own membership, refusing if they're the last owner.
func (*Store) RecoveryLeft ¶ added in v0.5.0
RecoveryLeft counts the unused recovery codes.
func (*Store) RegenerateRecovery ¶ added in v0.5.0
RegenerateRecovery replaces every recovery code.
func (*Store) RemoveMember ¶
RemoveMember drops a user from a team, refusing to remove the last owner.