trusteddevice

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CookieName = "autentico_trusted_device"

Variables

This section is empty.

Functions

func CreateTrustedDevice

func CreateTrustedDevice(device TrustedDevice) error

func IsDeviceTrusted

func IsDeviceTrusted(userID string, r *http.Request) bool

IsDeviceTrusted returns true if the request carries a valid, non-expired trusted device token that belongs to the given user.

func ReadCookie

func ReadCookie(r *http.Request) string

ReadCookie returns the trusted device token from the request, or "" if absent.

func SetCookie

func SetCookie(w http.ResponseWriter, deviceID string, expiry time.Duration)

SetCookie writes the trusted device cookie with the given token and expiry.

func UpdateLastUsed

func UpdateLastUsed(id string) error

Types

type TrustedDevice

type TrustedDevice struct {
	ID         string // token stored in cookie
	UserID     string
	DeviceName string
	CreatedAt  time.Time
	LastUsedAt time.Time
	ExpiresAt  time.Time
}

func TrustedDeviceByID

func TrustedDeviceByID(id string) (*TrustedDevice, error)

Jump to

Keyboard shortcuts

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