model

package
v3.13.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 9 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrForbidden          = errors.New("forbidden access")
	ErrUnknownUser        = errors.New("unknown user")
	ErrMalformedContent   = errors.New("malformed content")
	ErrUnavailableService = errors.New("unavailable service")
	ErrInvalidCredentials = errors.New("invalid credentials")
)
View Source
var ErrUnknownUserKind = errors.New("unknown UserKind")
View Source
var UserKinds = sync.OnceValue(func() []UserKind {
	count := len(_UserKind_index) - 1
	values := make([]UserKind, count)

	for i := range count {
		values[i] = UserKind(i)
	}

	return values
})

Functions

func StoreUser

func StoreUser(ctx context.Context, user User) context.Context

Types

type Authentication

type Authentication interface {
	GetUser(context.Context, http.ResponseWriter, *http.Request) (User, error)
	OnUnauthorized(http.ResponseWriter, *http.Request, error)
	Logout(http.ResponseWriter, *http.Request)
}

type Authorization

type Authorization interface {
	IsAuthorized(context.Context, *http.Request, User) bool
	OnForbidden(http.ResponseWriter, *http.Request, User)
}

type DiscordUser

type DiscordUser struct {
	Username string `json:"global_name"`
	Avatar   string `json:"avatar"`
	ID       string `json:"id"`
}

func (DiscordUser) GetID

func (du DiscordUser) GetID() string

type GitHubUser

type GitHubUser struct {
	Login string `json:"login"`
	ID    uint64 `json:"id"`
}

func (GitHubUser) GetID

func (gu GitHubUser) GetID() uint64

type GoogleUser

type GoogleUser struct {
	Sub     string `json:"sub"`
	Name    string `json:"name"`
	Picture string `json:"picture"`
}

func (GoogleUser) GetID

func (gu GoogleUser) GetID() string

type OAuthClaim

type OAuthClaim struct {
	Token *oauth2.Token `json:"token"`
	User  User          `json:"user"`
}

type Storage

type Storage interface {
	Create(context.Context, string) (User, error)
	Delete(context.Context, User) error
}

type User

type User struct {
	ID    string   `json:"id"`
	Name  string   `json:"name"`
	Image string   `json:"image"`
	Kind  UserKind `json:"kind"`
}

func NewUser

func NewUser(name string) User

func ReadUser

func ReadUser(ctx context.Context) (output User)

type UserKind

type UserKind int
const (
	Invite UserKind = iota
	GitHub
	Discord
	Basic
	Google
)

func ParseUserKind

func ParseUserKind(value string) (UserKind, error)

func (UserKind) MarshalText added in v3.13.4

func (uk UserKind) MarshalText() ([]byte, error)

func (UserKind) String

func (i UserKind) String() string

func (*UserKind) UnmarshalText added in v3.13.4

func (uk *UserKind) UnmarshalText(b []byte) error

Jump to

Keyboard shortcuts

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