session

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package session provides session authentication and management for the application.

Index

Constants

View Source
const (
	ApiKeyHeader    = "ApiKey"
	ApiKeyParameter = "apikey"
)

Variables

View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

func AddVisitedPluginHook added in v0.25.0

func AddVisitedPluginHook(ctx context.Context, pluginID string, hookType hook.TriggerEnum) context.Context

func CheckAllowPublicWithoutAuth added in v0.10.0

func CheckAllowPublicWithoutAuth(c ExternalAccessConfig, r *http.Request) error

func GetCurrentUserID

func GetCurrentUserID(ctx context.Context) *string

GetCurrentUserID gets the current user id from the provided context

func LogExternalAccessError added in v0.10.0

func LogExternalAccessError(err ExternalAccessError)

func SetCurrentUserID

func SetCurrentUserID(ctx context.Context, userID string) context.Context

Types

type ExternalAccessConfig added in v0.14.0

type ExternalAccessConfig interface {
	HasCredentials() bool
	GetDangerousAllowPublicWithoutAuth() bool
	GetSecurityTripwireAccessedFromPublicInternet() string
	IsNewSystem() bool
}

type ExternalAccessError added in v0.10.0

type ExternalAccessError net.IP

func CheckExternalAccessTripwire added in v0.10.0

func CheckExternalAccessTripwire(c ExternalAccessConfig) *ExternalAccessError

func (ExternalAccessError) Error added in v0.10.0

func (e ExternalAccessError) Error() string

type InvalidCredentialsError added in v0.21.0

type InvalidCredentialsError struct {
	Username string
}

func (InvalidCredentialsError) Error added in v0.21.0

func (e InvalidCredentialsError) Error() string

type SessionConfig added in v0.14.0

type SessionConfig interface {
	GetUsername() string
	GetAPIKey() string

	GetSessionStoreKey() []byte
	GetMaxSessionAge() int
	ValidateCredentials(username string, password string) bool
}

type Store

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

func NewStore

func NewStore(c SessionConfig) *Store

func (*Store) Authenticate

func (s *Store) Authenticate(w http.ResponseWriter, r *http.Request) (userID string, err error)

func (*Store) GetSessionUserID

func (s *Store) GetSessionUserID(w http.ResponseWriter, r *http.Request) (string, error)

func (*Store) Login

func (s *Store) Login(w http.ResponseWriter, r *http.Request) error

func (*Store) Logout

func (s *Store) Logout(w http.ResponseWriter, r *http.Request) error

func (*Store) MakePluginCookie

func (s *Store) MakePluginCookie(ctx context.Context) *http.Cookie

func (*Store) VisitedPluginHandler

func (s *Store) VisitedPluginHandler() func(http.Handler) http.Handler

type VisitedPluginHook added in v0.25.0

type VisitedPluginHook struct {
	PluginID string
	HookType hook.TriggerEnum
}

func GetVisitedPluginHooks added in v0.25.0

func GetVisitedPluginHooks(ctx context.Context) []VisitedPluginHook

Jump to

Keyboard shortcuts

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