sessions

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package sessions implements some helpers for getting started with indieauth.

This is basically a wrapper for gorilla/sessions, some handlers for sign-in, callback and sign-out, and a couple of handlers for protecting routes. It assumes you only need to authenticate a single user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sessions

type Sessions struct {

	// Handler to use when Shield fails
	DefaultSignedOut http.Handler
	// Path to redirect to on sign-in/out
	Root string
	// contains filtered or unexported fields
}

Sessions provides some handlers for authenticating a single user with indieauth.

func New

func New(me, secret string, auth *indieauth.AuthenticationConfig) (*Sessions, error)

New creates a new Sessions.

func (*Sessions) Callback

func (s *Sessions) Callback() http.HandlerFunc

Callback should be assigned to the redirectURL you configured for indieauth.

func (*Sessions) Choose

func (s *Sessions) Choose(signedIn, signedOut http.Handler) http.HandlerFunc

Choose allows you to switch between two handlers depending on whether the expected user is signed in or not.

func (*Sessions) Shield

func (s *Sessions) Shield(signedIn http.Handler) http.HandlerFunc

Shield will let the request continue if the expected user is signed in, otherwise they will be shown the DefaultSignedOut handler.

func (*Sessions) SignIn

func (s *Sessions) SignIn() http.HandlerFunc

SignIn should be assigned to a route like /sign-in, it redirects users to the correct endpoint.

func (*Sessions) SignOut

func (s *Sessions) SignOut() http.HandlerFunc

SignOut will remove the session cookie for the user.

Jump to

Keyboard shortcuts

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