auth

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package auth provides shared HMAC-signed session helpers used by glance and epoch for SSO cookie management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomState

func RandomState() string

RandomState returns a cryptographically random 32-character hex string suitable for OAuth state parameters and CSRF nonces.

func SignSession

func SignSession(sess Session, key []byte) string

SignSession encodes and HMAC-signs a session into a cookie value.

Types

type Session

type Session struct {
	User  string `json:"u"`
	Email string `json:"e"`
	Exp   int64  `json:"x"` // unix timestamp
}

Session holds the claims embedded in an HMAC-signed cookie.

func VerifySession

func VerifySession(cookie string, key []byte) (*Session, bool)

VerifySession validates the HMAC signature and decodes the session. Returns nil and false if the signature is invalid or decoding fails.

Jump to

Keyboard shortcuts

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