authkit initial
This commit is contained in:
parent
5173b0a43d
commit
134393fbca
43 changed files with 5188 additions and 1 deletions
75
models.go
Normal file
75
models.go
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package authkit
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID uuid.UUID
|
||||
Email string
|
||||
EmailNormalized string
|
||||
EmailVerifiedAt *time.Time
|
||||
PasswordHash string
|
||||
SessionVersion int
|
||||
FailedLogins int
|
||||
LastLoginAt *time.Time
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
IDHash []byte
|
||||
UserID uuid.UUID
|
||||
UserAgent string
|
||||
IP netip.Addr
|
||||
CreatedAt time.Time
|
||||
LastSeenAt time.Time
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
type TokenKind string
|
||||
|
||||
const (
|
||||
TokenEmailVerify TokenKind = "email_verify"
|
||||
TokenPasswordReset TokenKind = "password_reset"
|
||||
TokenMagicLink TokenKind = "magic_link"
|
||||
TokenRefresh TokenKind = "refresh"
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
Hash []byte
|
||||
Kind TokenKind
|
||||
UserID uuid.UUID
|
||||
ChainID *string
|
||||
ConsumedAt *time.Time
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
type APIKey struct {
|
||||
IDHash []byte
|
||||
OwnerID uuid.UUID
|
||||
Name string
|
||||
Abilities []string
|
||||
LastUsedAt *time.Time
|
||||
CreatedAt time.Time
|
||||
ExpiresAt *time.Time
|
||||
RevokedAt *time.Time
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Description string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Permission struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Description string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue