token

package
v0.13.0-alpha.26 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAuth = fmt.Errorf("no authorization header found")

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	NoRateLimit   bool `json:"no_rate_limit,omitempty"`
	NoAllowlist   bool `json:"no_allowlist,omitempty"`
	NoBlock       bool `json:"no_block,omitempty"`
	AllowTagsList bool `json:"allow_tags_list,omitempty"`
}

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(
	tokenDecoder *Decoder,
	tokenURL string,
) *Authenticator

func (*Authenticator) Authenticate

func (c *Authenticator) Authenticate(rw http.ResponseWriter, r *http.Request)

func (*Authenticator) Authorization

func (c *Authenticator) Authorization(r *http.Request) (Token, error)

type Decoder

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

func NewDecoder

func NewDecoder(verifier *signing.Verifier) *Decoder

func (*Decoder) Decode

func (p *Decoder) Decode(code string) (t Token, err error)

type Encoder

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

func NewEncoder

func NewEncoder(signer *signing.Signer) *Encoder

func (*Encoder) Encode

func (p *Encoder) Encode(t Token) (code string, err error)

type Generator

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

func NewGenerator

func NewGenerator(
	tokenEncoder *Encoder,
	authFunc func(r *http.Request, userinfo *url.Userinfo) (Attribute, bool),
	logger *slog.Logger,
) *Generator

func (*Generator) ServeHTTP

func (g *Generator) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Token

type Token struct {
	ExpiresAt time.Time `json:"expires_at,omitempty"`
	Scope     string    `json:"scope,omitempty"`
	Service   string    `json:"service,omitempty"`

	Account string `json:"account,omitempty"`
	Image   string `json:"image,omitempty"`

	Attribute `json:"attribute,omitempty"`
}

Jump to

Keyboard shortcuts

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