session

package
v1.8.17 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Get = func(key string) ([]string, bool) {
	log.Debug("get value from cache")
	header, exists := SessionCache.Get(key)
	var cachedDatasets []string
	if header != nil {
		cachedDatasets = header.(DatasetCache).Datasets
	} else {
		cachedDatasets = nil
	}
	log.Debugf("cache response, exists=%t, datasets=%s", exists, cachedDatasets)

	return cachedDatasets, exists
}

Get returns a value from cache at key

View Source
var NewSessionKey = func() string {
	log.Debug("generating new session key")

	// Generate a new key until one is generated, which doesn't already exist
	var sessionKey string
	exists := true
	for exists {

		key := uuid.New().String()
		sessionKey = key

		_, exists = Get(key)
	}

	log.Debug("new session key generated")

	return sessionKey
}

NewSessionKey generates a session key used for storing dataset permissions, and checks that it doesn't already exist

View Source
var SessionCache *ristretto.Cache

SessionCache stores dataset permission lists

Functions

func InitialiseSessionCache

func InitialiseSessionCache() (*ristretto.Cache, error)

InitialiseSessionCache creates a cache manager that stores keys and values in memory

func Set

func Set(key string, datasets []string)

Types

type DatasetCache

type DatasetCache struct {
	Datasets []string
}

DatasetCache stores the dataset permissions and information whether this information has already been checked or not. This information can then be used to skip the time-costly authentication middleware DatasetCache==nil, session doesn't exist DatasetCache.Datasets==nil, session exists, user has no permissions (this case is not used in middleware.go) DatasetCache.Datasets==[]string{}, session exists, user has permissions

Jump to

Keyboard shortcuts

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