Documentation
¶
Overview ¶
Package postgres implements gouncer's user and session persistence in a PostgreSQL schema of its own.
Index ¶
- Variables
- func Migrate(ctx context.Context, databaseURL string) error
- type UserStore
- func (s *UserStore) CreateSession(ctx context.Context, session gouncer.Session) error
- func (s *UserStore) CreateUser(ctx context.Context, u gouncer.User) error
- func (s *UserStore) DeleteExpiredSessions(ctx context.Context, now time.Time) (int64, error)
- func (s *UserStore) DeleteSession(ctx context.Context, tokenHash []byte) error
- func (s *UserStore) ListUsers(ctx context.Context) ([]gouncer.User, error)
- func (s *UserStore) SetUserDisabled(ctx context.Context, id uuid.UUID, disabled bool) error
- func (s *UserStore) UserByEmail(ctx context.Context, email string) (gouncer.User, error)
- func (s *UserStore) UserBySession(ctx context.Context, tokenHash []byte, now time.Time) (gouncer.User, error)
Constants ¶
This section is empty.
Variables ¶
var Migrations embed.FS
Migrations holds the auth schema migration files applied by goose.
Functions ¶
Types ¶
type UserStore ¶
type UserStore struct {
// contains filtered or unexported fields
}
UserStore persists users and their sessions in the auth schema.
func NewUserStore ¶
NewUserStore returns a UserStore backed by pool.
func (*UserStore) CreateSession ¶
CreateSession stores a login session.
func (*UserStore) CreateUser ¶
CreateUser stores a new user, or gouncer.ErrEmailTaken when the email is already in use.
func (*UserStore) DeleteExpiredSessions ¶
DeleteExpiredSessions removes sessions that expired at or before now and returns how many it removed.
func (*UserStore) DeleteSession ¶
DeleteSession removes the session with the given token hash, if any.
func (*UserStore) ListUsers ¶
ListUsers returns every user ordered by name. The listing never reads password hashes, so the returned users carry none.
func (*UserStore) SetUserDisabled ¶
SetUserDisabled updates whether the user may log in, revoking every session the user holds when disabling so a later re-enable cannot resurrect them, or returns gouncer.ErrUserNotFound when no such user exists.
func (*UserStore) UserByEmail ¶
UserByEmail returns the user owning the email, or gouncer.ErrUserNotFound if none exists.