session

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package session handles session and token storage for authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractRawToken

func ExtractRawToken(tokenData string) string

ExtractRawToken extracts the raw machine token value from a token string. PHP Terminus stores tokens as JSON with token, email, and date fields. This function handles both formats: raw token strings and PHP-style JSON.

Types

type Session

type Session struct {
	SessionToken string `json:"session"`
	UserID       string `json:"user_id"`
	ExpiresAt    int64  `json:"expires_at"`
}

Session represents an authenticated session

func (*Session) IsExpired

func (s *Session) IsExpired() bool

IsExpired returns true if the session has expired

type Store

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

Store handles session and token persistence

func NewStore

func NewStore(cacheDir string) *Store

NewStore creates a new session store

func (*Store) DeleteSession

func (s *Store) DeleteSession() error

DeleteSession deletes the session file

func (*Store) DeleteToken

func (s *Store) DeleteToken(email string) error

DeleteToken deletes a machine token

func (*Store) ListTokens

func (s *Store) ListTokens() ([]string, error)

ListTokens returns a list of saved token emails

func (*Store) LoadSession

func (s *Store) LoadSession() (*Session, error)

LoadSession loads a session from disk

func (*Store) LoadToken

func (s *Store) LoadToken(email string) (string, error)

LoadToken loads a machine token from disk

func (*Store) SaveSession

func (s *Store) SaveSession(session *Session) error

SaveSession saves a session to disk

func (*Store) SaveToken

func (s *Store) SaveToken(email, token string) error

SaveToken saves a machine token to disk

Jump to

Keyboard shortcuts

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