Documentation
¶
Index ¶
- Constants
- func CreateTrustedDevice(device TrustedDevice) error
- func DeleteTrustedDevice(id string) error
- func IsDeviceTrusted(userID string, r *http.Request) bool
- func ReadCookie(r *http.Request) string
- func SetCookie(w http.ResponseWriter, deviceID string, expiry time.Duration)
- func UpdateLastUsed(id string) error
- type TrustedDevice
Constants ¶
View Source
const CookieName = "autentico_trusted_device"
Variables ¶
This section is empty.
Functions ¶
func CreateTrustedDevice ¶
func CreateTrustedDevice(device TrustedDevice) error
func DeleteTrustedDevice ¶ added in v1.3.2
func IsDeviceTrusted ¶
IsDeviceTrusted returns true if the request carries a valid, non-expired trusted device token that belongs to the given user.
func ReadCookie ¶
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 ¶
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)
func TrustedDevicesByUserID ¶ added in v1.3.2
func TrustedDevicesByUserID(userID string) ([]*TrustedDevice, error)
Click to show internal directories.
Click to hide internal directories.