Help us shape the future of Go! Take the 2026 Go Developer Survey

sessions

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenID

func GenID() (string, error)

GenID generates a session id

Types

type Sessions

type Sessions struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Sessions pool

func New

func New() Sessions

New inits a new sessions struct

func (*Sessions) Authorize

func (s *Sessions) Authorize(accessToken string, projectName string) bool

Authorize user to access to matching ressource

func (*Sessions) Get

func (s *Sessions) Get(accessToken string) (*UserData, bool)

Get UserData from session pool

func (*Sessions) Len

func (s *Sessions) Len() int

Len returns the length of the pool

func (*Sessions) Prune

func (s *Sessions) Prune()

Prune sessions will remove expired sessions from sessions pool

func (*Sessions) Put

func (s *Sessions) Put(sessionID string, accessToken string, expires time.Time, project *gitlab.ProjectInfo)

Put UserData into session pool

func (*Sessions) Remove

func (s *Sessions) Remove(accessToken string)

Remove UserData from session pool

func (*Sessions) Start

func (s *Sessions) Start(delay uint) error

Start will start the session handler in the background and prune expired sessions

type UserData

type UserData struct {
	Expires time.Time
	Project *gitlab.ProjectInfo
	// contains filtered or unexported fields
}

UserData user sessions contains user data

func (*UserData) GetToken

func (ud *UserData) GetToken() string

GetToken return the accessToken value

func (*UserData) IsValid

func (ud *UserData) IsValid() bool

IsValid is used to check is user data is expired

func (*UserData) MatchRequestedProject

func (ud *UserData) MatchRequestedProject(requestedProject string) bool

MatchRequestedProject check is this user session match the required project

Jump to

Keyboard shortcuts

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