cookie

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCookieName = "whawty-nginx-sso"
	DefaultExpire     = 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name   string                 `yaml:"name"`
	Domain string                 `yaml:"domain"`
	Secure bool                   `yaml:"secure"`
	Expire time.Duration          `yaml:"expire"`
	Keys   []SignerVerifierConfig `yaml:"keys"`
}

type Controller

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

func NewController

func NewController(conf *Config, infoLog, dbgLog *log.Logger) (*Controller, error)

func (*Controller) Mint

func (c *Controller) Mint(p Payload) (value string, opts Options, err error)

func (*Controller) Options

func (c *Controller) Options() (opts Options)

func (*Controller) Verify

func (c *Controller) Verify(value string) (p Payload, err error)

type Ed25519Config

type Ed25519Config struct {
	PrivKey     *string `yaml:"private-key"`
	PrivKeyFile *string `yaml:"private-key-file"`
	PubKey      *string `yaml:"public-key"`
	PubKeyFile  *string `yaml:"public-key-file"`
}

type Ed25519SignerVerifier

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

func NewEd25519SignerVerifier

func NewEd25519SignerVerifier(context string, conf *Ed25519Config) (*Ed25519SignerVerifier, error)

func (Ed25519SignerVerifier) Algo

func (s Ed25519SignerVerifier) Algo() string

func (Ed25519SignerVerifier) CanSign

func (s Ed25519SignerVerifier) CanSign() bool

func (Ed25519SignerVerifier) Sign

func (s Ed25519SignerVerifier) Sign(payload []byte) ([]byte, error)

func (Ed25519SignerVerifier) Verify

func (s Ed25519SignerVerifier) Verify(payload, signature []byte) error

type Options

type Options struct {
	Name   string
	MaxAge int
	Domain string
	Secure bool
}

type Payload

type Payload struct {
	Username string `json:"u"`
	Expires  int64  `json:"e"`
}

func (*Payload) Decode

func (p *Payload) Decode(payload []byte) error

func (*Payload) Encode

func (p *Payload) Encode() []byte

type SignerVerifier

type SignerVerifier interface {
	Algo() string
	CanSign() bool
	Sign(payload []byte) ([]byte, error)
	Verify(payload, signature []byte) error
}

type SignerVerifierConfig

type SignerVerifierConfig struct {
	Name    string         `yaml:"name"`
	Ed25519 *Ed25519Config `yaml:"ed25519"`
}

type Value

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

func (*Value) FromString

func (v *Value) FromString(encoded string) (err error)

func (*Value) String

func (v *Value) String() string

Jump to

Keyboard shortcuts

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