models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	ID        string `gorm:"primaryKey"`
	Token     string `gorm:"uniqueIndex;not null"`
	TokenType string `gorm:"not null;default:'Bearer'"`
	UserID    string `gorm:"not null;index"`
	ClientID  string `gorm:"not null;index"`
	Scopes    string `gorm:"not null"` // space-separated scopes
	ExpiresAt time.Time
	CreatedAt time.Time
}

func (*AccessToken) IsExpired

func (t *AccessToken) IsExpired() bool

type DeviceCode

type DeviceCode struct {
	DeviceCode   string `gorm:"primaryKey"`
	UserCode     string `gorm:"uniqueIndex;not null"`
	ClientID     string `gorm:"not null;index"`
	Scopes       string `gorm:"not null"` // space-separated scopes
	ExpiresAt    time.Time
	Interval     int    // polling interval in seconds
	UserID       string // filled after authorization
	Authorized   bool   `gorm:"default:false"`
	AuthorizedAt time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func (*DeviceCode) IsExpired

func (d *DeviceCode) IsExpired() bool

type OAuthClient

type OAuthClient struct {
	ClientID     string `gorm:"primaryKey"`
	ClientSecret string `gorm:"not null"` // bcrypt hashed secret
	ClientName   string `gorm:"not null"`
	Description  string `gorm:"type:text"`
	Scopes       string `gorm:"not null"`                       // space-separated scopes
	GrantTypes   string `gorm:"not null;default:'device_code'"` // comma-separated grant types
	RedirectURIs string `gorm:"type:text"`                      // comma-separated redirect URIs
	IsActive     bool   `gorm:"not null;default:true"`
	CreatedBy    string // User ID who created this client
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func (OAuthClient) TableName

func (OAuthClient) TableName() string

TableName overrides the table name used by OAuthClient to `oauth_client`

type User

type User struct {
	ID           string `gorm:"primaryKey"`
	Username     string `gorm:"uniqueIndex;not null"`
	PasswordHash string `gorm:"not null"`
	Role         string `gorm:"not null;default:'user'"` // "admin" or "user"
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func (*User) IsAdmin added in v0.2.0

func (u *User) IsAdmin() bool

IsAdmin returns true if the user has admin role

Jump to

Keyboard shortcuts

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