session

package
v1.10.57 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Get = func(key string) (Cache, bool) {
	log.Debug("get value from cache")
	cachedItem, exists := SessionCache.Get(key)
	var cached Cache
	if exists {

		cached = cachedItem.(Cache)
	}
	log.Debugf("cache response, exists=%t, cached=%v", exists, cached)

	return cached, exists
}

Get returns a cache item from the session storage 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 is the in-memory storage holding session keys and interfaces containing cached data

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, toCache Cache)

Types

type Cache added in v1.10.1

type Cache struct {
	Datasets []string
}

Cache 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 Cache==nil, session doesn't exist Cache.Datasets==nil, session exists, user has no permissions (this case is not used in middleware.go) Cache.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