authsession

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticated

func Authenticated(ctx context.Context) bool

func ClearSession

func ClearSession(store sessions.Store, r *http.Request, w http.ResponseWriter) error

func SetIdentityCtx

func SetIdentityCtx(parent context.Context, session *AuthSession) context.Context

func SetSession

func SetSession(store sessions.Store, r *http.Request, w http.ResponseWriter, s *AuthSession) error

Types

type AuthSession

type AuthSession struct {
	Nonce    *string
	Identity *Identity
}

func GetSession

func GetSession(store sessions.Store, r *http.Request) (*AuthSession, error)

type Claims

type Claims []claim

func (*Claims) Add

func (c *Claims) Add(name string, value string)

func (*Claims) Contains

func (c *Claims) Contains(claim string) bool

func (*Claims) Has

func (c *Claims) Has(claim string, value string) bool

func (*Claims) IsAdmin added in v0.9.0

func (c *Claims) IsAdmin() bool

func (*Claims) MakeAdmin added in v0.9.0

func (c *Claims) MakeAdmin()

type ClaimsMiddleware

type ClaimsMiddleware func(user *Identity) error

type Identity

type Identity struct {
	// Provider is the name of the authentication provider
	// that authenticated (created) this Identity struct.
	Provider string
	// Subject is the canonical identifier for this Identity.
	Subject string
	// Name is the name of the person this Identity refers to.
	// It may be empty.
	Name string
	// Email is the email address of the person this Identity refers to.
	// It may be empty.
	Email string
	// Claims are any additional claims that middlewares have added to this Identity.
	Claims Claims
}

func CurrentUser

func CurrentUser(ctx context.Context) (*Identity, error)

Jump to

Keyboard shortcuts

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