Documentation
¶
Index ¶
- Constants
- Variables
- func CleanupInvalidTokens(tokenDB *dbwrapper.DBWrapper) (int64, error)
- func InitDB(dbPath string) (*dbwrapper.DBWrapper, error)
- func InitEncryptedDB(dbPath string, dbKey string) (*dbwrapper.DBWrapper, error)
- func IsInvalidPurpose(err error) bool
- func IsInvalidUserId(err error) bool
- func IsTokenNotFound(err error) bool
- func IsTokenNotValid(err error) bool
- func IsValid(tokenDB *dbwrapper.DBWrapper, tokenInfo TokenInfo) (bool, error)
- func NewErrInvalidPurpose(purpose string) error
- func NewErrInvalidRow(missingColumn string) error
- func NewErrInvalidUserId(userID string) error
- func NewErrTokenNotFound(condition string) error
- func RevokeAllTokensForUser(db *dbwrapper.DBWrapper, userID string) error
- func RevokeToken(tokenDB *dbwrapper.DBWrapper, tokenID string) error
- type TokenDetails
- type TokenInfo
Constants ¶
View Source
const ( PurposeLoginSession = "login_session" // User authentication session PurposeUserDelete = "user_delete" // Account deletion confirmation PurposePasswordReset = "password_reset" // Password reset flow PurposeAPIKey = "api_key" // Long-lived API access PurposeEmailVerify = "email_verify" // Email verification )
View Source
const DateTimeLayout = time.RFC3339
Variables ¶
View Source
var ( ErrInitialisation = errors.New("failed initialising token database") ErrInvalidPurpose = errors.New("invalid purpose") ErrInvalidRow = errors.New("invalid database row") ErrInvalidUserId = errors.New("invalid user ID") ErrSQLInjectionAttemptDetected = errors.New("SQL injection detected") ErrTokenDatabaseAlreadyExists = errors.New("token database already exists") ErrTokenNotFound = errors.New("token not found") ErrTokenNotValid = errors.New("token is not valid") )
View Source
var HashConfig hashwrapper.HashConfig = hashwrapper.HashConfig{ Time: uint32(1), Memory: uint32(32), Threads: uint8(1), KeyLen: uint32(4), SaltLen: 2, }
Functions ¶
func InitEncryptedDB ¶
func IsInvalidPurpose ¶
func IsInvalidUserId ¶
func IsTokenNotFound ¶
func IsTokenNotValid ¶
func NewErrInvalidPurpose ¶
func NewErrInvalidRow ¶
func NewErrInvalidUserId ¶
func NewErrTokenNotFound ¶
func RevokeAllTokensForUser ¶
Types ¶
type TokenDetails ¶
type TokenDetails struct {
TokenHash string
TokenID uuid.UUID
UserID uuid.UUID
Purpose string
CreatedAt time.Time
ExpiresAt time.Time
RevokedAt sql.NullString
DeviceFingerprint string
UserAgent string
IsValid bool
}
func GetAllTokensForUser ¶
func GetAllTokensForUser(tokenDB *dbwrapper.DBWrapper, userID string) ([]*TokenDetails, error)
func GetTokenDetails ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.