models

package
v0.0.0-...-7c6b4a0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	ID             string `gorm:"column:id;primaryKey;type:uuid;default:uuid_generate_v4()" json:"-"`
	Owner          User   `gorm:"foreignKey:OwnerSubject;references:Subject;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	OwnerSubject   string
	ClientID       string `gorm:"column:client_id;uniqueIndex;type:char(32);not null" json:"-"`
	ClientSecret   string `gorm:"column:client_secret;type:varchar(100);not null" json:"-"`
	Name           string `gorm:"column:name;type:varchar(20);not null" json:"-"`
	Description    string `gorm:"column:description;type:varchar(50)" json:"-"`
	LoginURL       string `gorm:"column:login_url;type:text" json:"-"`
	CallbackURL    string `gorm:"column:callback_url;type:text" json:"-"`
	LogoutURL      string `gorm:"column:logout_url;type:text" json:"-"`
	Metadata       string `gorm:"column:metadata;type:text" json:"-"`
	Locked         bool   `gorm:"column:locked;default:false" json:"-"`
	CreatedAt      int64  `gorm:"column:created_at;autoCreateTime" json:"-"`
	UpdatedAt      int64  `gorm:"column:updated_at;autoUpdateTime" json:"-"`
	LastAuthorize  int64  `gorm:"column:last_authorize;default:0" json:"-"`
	AuthorizeCount int    `gorm:"column:authorize_count;default:0" json:"-"`
}

CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; Owner field is populated only when .Preload("Owner") is appended to the query pipeline

type ApplicationOrmer

type ApplicationOrmer interface {
	GetOneByClientID(clientID string) (application Application, err error)
	GetAllByOwnerSubject(ownerSubject string) (applications []Application, err error)
	GetAll() (applications []Application, err error)
	InsertApplication(application Application) (clientID string, err error)
	UpdateApplication(application Application) (err error)
	IncrementAuthorizeCount(application Application) (err error)
	DeleteApplication(clientID string) (err error)
}

func NewApplicationOrmer

func NewApplicationOrmer(db *gorm.DB) ApplicationOrmer

type Log

type Log struct {
	ID                  string `gorm:"column:id;primaryKey;type:uuid;default:uuid_generate_v4()" json:"-"`
	User                User   `gorm:"foreignKey:UserSubject;references:Subject;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	UserSubject         sql.NullString
	Application         Application `gorm:"foreignKey:ApplicationClientID;default:null;references:ClientID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	ApplicationClientID sql.NullString
	Type                string `gorm:"column:type;type:char(4);index:idx_type;not null" json:"-"`
	Severity            string `gorm:"column:severity;type:char(1);not null" json:"-"`
	Description         string `gorm:"column:description;type:text" json:"-"`
	CreatedAt           int64  `gorm:"column:created_at;autoCreateTime" json:"-"`
}

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

type LogOrmer

type LogOrmer interface {
	GetAllByUserSubject(userSubject string) (logs []Log, err error)
	GetAllActivityByApplicationClientID(applicationClientID string) (logs []Log, err error)
	GetAllAdmin() (logs []Log, err error)
	InsertLog(log Log) (err error)
}

func NewLogOrmer

func NewLogOrmer(db *gorm.DB) LogOrmer

type User

type User struct {
	Subject       string `gorm:"column:sub;primaryKey;type:uuid;default:uuid_generate_v4()" json:"-"`
	Superuser     bool   `gorm:"column:superuser;default:false" json:"-"`
	GivenName     string `gorm:"column:given_name;type:varchar(20);not null" json:"-"`
	FamilyName    string `gorm:"column:family_name;type:varchar(12);not null" json:"-"`
	Username      string `gorm:"column:preferred_username;uniqueIndex;type:varchar(12);not null" json:"-"`
	Email         string `gorm:"column:email;uniqueIndex;type:varchar(50);not null" json:"-"`
	EmailVerified bool   `gorm:"column:email_verified;default:false" json:"-"`
	Password      string `gorm:"column:password;type:varchar(100);not null" json:"-"`
	TOTPSecret    string `gorm:"column:totp_secret;type:varchar(32);default:'-'" json:"-"`
	Metadata      string `gorm:"column:metadata;type:text" json:"-"`
	CreatedAt     int64  `gorm:"column:created_at;autoCreateTime" json:"-"`
	UpdatedAt     int64  `gorm:"column:updated_at;autoUpdateTime" json:"-"`
	LastLogin     int64  `gorm:"column:last_login;default:0" json:"-"`
	LoginCount    int    `gorm:"column:login_count;default:0" json:"-"`
	RecentFailure bool   `gorm:"column:recent_failure;default:false" json:"-"`
}

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

func (User) EnabledTOTP

func (user User) EnabledTOTP() (enabled bool)

type UserOrmer

type UserOrmer interface {
	GetOneBySubject(subject string) (user User, err error)
	GetOneByUsername(username string) (user User, err error)
	GetOneByEmail(email string) (user User, err error)
	GetAll() (users []User, err error)
	InsertUser(user User) (subject string, err error)
	UpdateUser(user User) (err error)
	UpdateUserSuperuser(user User) (err error)
	FlagRecentFailure(user User, failed bool) (err error)
	IncrementLoginCount(user User) (err error)
}

func NewUserOrmer

func NewUserOrmer(db *gorm.DB) UserOrmer

Jump to

Keyboard shortcuts

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