user

package
v0.0.0-...-052274c Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CookieKey is the name of the cookie used for authentication
	CookieKey = "u"

	// CookieMaxAge is the expiration age (in seconds) used for the authentication
	// cookie
	CookieMaxAge = 3600
)

Variables

This section is empty.

Functions

func CreateCookie

func CreateCookie(data string, secure bool) *http.Cookie

CreateCookie creates a new http.Cookie for the user cookie.

Types

type Info

type Info struct {
	Email             string
	Name              string
	Picture           string
	LastAuthenticated time.Time
}

Info ...

func Decode

func Decode(c string, key []byte) (*Info, error)

Decode unmarshals an encoded and signed user.

func DecodeAndVerify

func DecodeAndVerify(c string, key []byte) (*Info, error)

DecodeAndVerify decodes the user but also validates that the encoded user object is still valid.

func DecodeFromRequest

func DecodeFromRequest(r *http.Request, key []byte) (*Info, error)

DecodeFromRequest decodes the user from the cookie found in the http.Request.

func (*Info) Encode

func (i *Info) Encode(key []byte) (string, error)

Encode the full user object as a base64 string that is signed with the given key. This value is suitable for use in a cookie.

Jump to

Keyboard shortcuts

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