session

package
v0.0.0-...-f8da852 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package session provides session storage and management.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

This section is empty.

Variables

View Source
var CleanupAction = func() {
	if n := entity.DeleteExpiredSessions(); n > 0 {
		event.AuditInfo([]string{"deleted %s"}, english.Plural(n, "expired session", "expired sessions"))
	} else {
		event.AuditDebug([]string{"found no expired sessions"})
	}
}

CleanupAction deletes sessions that have expired.

View Source
var PublicAuthToken = "234200000000000000000000000000000000000000000000"

PublicAuthToken is a static authentication token used in public mode.

PublicID is the SHA256 hash of the PublicAuthToken: a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f

Functions

func Cleanup

func Cleanup(interval time.Duration)

Cleanup starts a background worker that periodically deletes expired sessions.

func Shutdown

func Shutdown()

Shutdown shuts down the session watcher.

Types

type Session

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

Session represents a session store.

func New

func New(conf *config.Config) *Session

New creates a new session store with default values.

func (*Session) Create

func (s *Session) Create(u *entity.User, c *gin.Context, data *entity.SessionData) (m *entity.Session, err error)

Create initializes a new client session and returns it.

func (*Session) Delete

func (s *Session) Delete(id string) error

Delete removes a client session by id.

func (*Session) Exists

func (s *Session) Exists(id string) bool

Exists checks whether a client session with the specified ID exists.

func (*Session) Get

func (s *Session) Get(id string) (m *entity.Session, err error)

Get returns an existing client session.

func (*Session) New

func (s *Session) New(c *gin.Context) (m *entity.Session)

New creates a session with a context if it is specified.

func (*Session) Public

func (s *Session) Public() *entity.Session

Public returns a client session for use in public mode.

func (*Session) Save

func (s *Session) Save(m *entity.Session) (*entity.Session, error)

Save updates the client session or creates a new one if needed.

Jump to

Keyboard shortcuts

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