go-urlsh/models/multifactor.go

50 lines
1.2 KiB
Go
Raw Normal View History

2024-05-04 17:06:01 +02:00
package models
import (
"time"
"github.com/uptrace/bun"
)
type TokenRequest struct {
Token string `json:"token"`
}
type MFALoginTransaction struct {
bun.BaseModel `bun:"table:logintransactions"`
SessionKey string `bun:"sessionkey,pk"`
UserName string `bun:"username,notnull"`
Expires time.Time `bun:"expires,notnull"`
}
// TODO: Rework Scratch tokens:
// Only one Scratch token
// Possibility to regenerate scratch token
// mark Tokens as used
type MFAConfig struct {
bun.BaseModel `bun:"table:multifactor"`
ID int64 `bun:"id,pk,autoincrement"`
UserName string `bun:"username,notnull"`
2024-05-06 21:38:51 +02:00
TOTPSecret string `bun:"totp_secret,notnull"`
ExpiresAt time.Time `bun:"expires_at,notnull"`
2024-05-04 17:06:01 +02:00
Active bool `bun:"active,notnull"`
}
type MFAScratchCode struct {
bun.BaseModel `bun:"table:multifactor_scratchcodes"`
Code string `bun:"code,pk"`
UserName string `bun:"username,notnull"`
IsUsed bool `bun:"is_used,notnull"`
}
2024-05-04 17:06:01 +02:00
type MFATemplateObject struct {
Key string
Image string
}
type MFASetupResponse struct {
Error bool `json:"error"`
Message string `json:"message,omitempty"`
RecoveryTokens []string `json:"recovery_tokens,omitempty"`
}