copenhagen

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Configuration = map[string]any{
	"POSTGRES_HOST": "localhost:5432",
	"POSTGRES_USER": "copenhagen",
	"POSTGRES_PASS": "insecure",
	"POSTGRES_SSL":  false,
	"TOKEN_ISSUER":  hostname,
	"TOKEN_SECRET":  []byte("insecure"),
	"TOKEN_USE_TLS": false,
}
View Source
var ErrInvalidCredential = errors.New("invalid credential")

Functions

func Error added in v0.1.1

func Error(w http.ResponseWriter, r *http.Request, message string, code int, err error)

func Info added in v0.1.1

func Info(r *http.Request, message string, attrs ...slog.Attr)

func Mux

func Mux(ctx context.Context, db *sql.DB) http.Handler

Types

type Authentication

type Authentication struct {
	*sql.Stmt
}

func (Authentication) Middleware

func (middleware Authentication) Middleware(route http.HandlerFunc) http.HandlerFunc

type Authorization

type Authorization struct {
	*sql.Stmt
}

func (Authorization) Middleware

func (middleware Authorization) Middleware(route http.HandlerFunc) http.HandlerFunc

type Credential

type Credential struct {
	Email string
	Plain string
}

func (Credential) Authenticate

func (credential Credential) Authenticate(tx *sql.Tx) (*uuid.UUID, error)

type Email

type Email struct {
	User     uuid.UUID  `db:"user"`
	Verified *time.Time `db:"verified"`
	Data     string     `db:"data"`
}

func NewEmail

func NewEmail(user User, email string) Email

type LogOut

type LogOut struct {
	*sql.DB
}

func (LogOut) ServeHTTP

func (handler LogOut) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Revoke

type Revoke struct {
	*sql.DB
}

func (Revoke) ServeHTTP

func (handler Revoke) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SignIn

type SignIn struct {
	*sql.DB
}

func (SignIn) ServeHTTP

func (handler SignIn) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SignUp

type SignUp struct {
	*sql.DB
}

func (SignUp) ServeHTTP

func (handler SignUp) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Token

type Token struct {
	User    *uuid.UUID `db:"user"`
	Expires time.Time  `db:"expires"`
	Data    string     `db:"data"`
}

func NewToken

func NewToken(user *uuid.UUID, ttl time.Duration, audience ...string) (Token, error)

type User

type User struct {
	uuid.UUID `db:"user"`
	Salt      []byte `db:"salt"`
	Hash      []byte `db:"hash"`
}

func NewUser

func NewUser(password string) User

type Verification

type Verification struct {
	uuid.UUID `db:"link"`
	Code      [8]byte   `db:"code"`
	User      uuid.UUID `db:"user"`
	Expires   time.Time `db:"expires"`
	Data      string    `db:"data"`
}

func NewEmailVerification

func NewEmailVerification(email Email) Verification

type Verify

type Verify struct {
}

func (Verify) ServeHTTP

func (handler Verify) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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