session

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2018 License: MPL-2.0 Imports: 5 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// StorageSessionName ...
	StorageSessionName = "go_oauth2_server_session"
	// UserSessionKey ...
	UserSessionKey = "go_oauth2_server_user"
	// ErrSessonNotStarted ...
	ErrSessonNotStarted = errors.New("Session not started")
)

Functions

This section is empty.

Types

type Service

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

Service wraps session functionality

func NewService

func NewService(cnf *config.Config, sessionStore sessions.Store) *Service

NewService returns a new Service instance

func (*Service) ClearUserSession

func (s *Service) ClearUserSession() error

ClearUserSession deletes the user session

func (*Service) Close

func (s *Service) Close()

Close stops any running services

func (*Service) GetFlashMessage

func (s *Service) GetFlashMessage() (interface{}, error)

GetFlashMessage returns the first flash message

func (*Service) GetUserSession

func (s *Service) GetUserSession() (*UserSession, error)

GetUserSession returns the user session

func (*Service) SetFlashMessage

func (s *Service) SetFlashMessage(msg string) error

SetFlashMessage sets a flash message, useful for displaying an error after 302 redirection

func (*Service) SetSessionService

func (s *Service) SetSessionService(r *http.Request, w http.ResponseWriter)

SetSessionService sets the request and responseWriter on the session service

func (*Service) SetUserSession

func (s *Service) SetUserSession(userSession *UserSession) error

SetUserSession saves the user session

func (*Service) StartSession

func (s *Service) StartSession() error

StartSession starts a new session. This method must be called before other public methods of this struct as it sets the internal session object

type ServiceInterface

type ServiceInterface interface {
	SetSessionService(r *http.Request, w http.ResponseWriter)
	StartSession() error
	GetUserSession() (*UserSession, error)
	SetUserSession(userSession *UserSession) error
	ClearUserSession() error
	SetFlashMessage(msg string) error
	GetFlashMessage() (interface{}, error)
	Close()
}

ServiceInterface defines exported methods

type UserSession

type UserSession struct {
	ClientID     string
	Username     string
	AccessToken  string
	RefreshToken string
}

UserSession has user data stored in a session after logging in

Jump to

Keyboard shortcuts

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