auth

package
v0.9.0-rc.53 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 10 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 resolves the signed-in user from the session cookie.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *db.User

FromContext returns nil when nobody is signed in.

func NewContext

func NewContext(ctx context.Context, user *db.User) context.Context

Types

type Resolver

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

func NewResolver

func NewResolver(store *session.Store, sessions Sessions, users Users, log *slog.Logger) *Resolver

func (*Resolver) Middleware

func (r *Resolver) Middleware(next http.Handler) http.Handler

Middleware puts the signed-in user on the request context. Anonymous is not an error and not a separate branch: FromContext returns nil for it.

func (*Resolver) OnSeen

func (r *Resolver) OnSeen(f func(req *http.Request, key string, user *db.User))

type Sessions

type Sessions interface {
	SessionByKey(ctx context.Context, key string) (string, time.Time, error)
	DeleteSession(ctx context.Context, key string) error
}

type Users

type Users interface {
	UserForSession(ctx context.Context, id int64) (*db.User, string, error)
	BotByAPIKey(ctx context.Context, key string) (*db.User, error)
}

Jump to

Keyboard shortcuts

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