models

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicClient       string = "public"
	ConfidentialClient string = "confidential"
)
View Source
const (
	AccessToken  string = "access_token"
	RefreshToken string = "refresh_token"
	GrantToken   string = "grant_token"

	PublicScope    string = "public"
	ReadScope      string = "read"
	ReadWriteScope string = "read_write"
)

Variables

This section is empty.

Functions

func GenerateRandomString

func GenerateRandomString(n int) string

func IsValid

func IsValid(tagName string, model interface{}) bool

Types

type Action

type Action struct {
	UUID      string    `validate:"omitempty,uuid4" json:"uuid"`
	User      User      `validate:"exists" json:"-"`
	UserID    uint      `json:"user_id"`
	Client    Client    `validate:"exists" json:"-"`
	ClientID  uint      `json:"client_id"`
	Moment    int64     `json:"moment"`
	ExpiresIn int64     `json:"expires_in"`
	Ip        string    `validate:"required" json:"ip"`
	UserAgent string    `validate:"required" json:"user_agent"`
	Token     string    `validate:"omitempty,alphanum" json:"token"`
	Scopes    string    `validate:"required,scope" json:"scopes"`
	CreatedAt time.Time `json:"created_at"`
}

func RetrieveActionByToken

func RetrieveActionByToken(token string) Action

func RetrieveActionByUUID

func RetrieveActionByUUID(uuid string) Action

func (*Action) Delete

func (action *Action) Delete()

func (*Action) Save

func (action *Action) Save() error

func (*Action) WithinExpirationWindow

func (action *Action) WithinExpirationWindow() bool

type Client

type Client struct {
	Model
	UUID        string `gorm:"not null;unique;index" validate:"omitempty,uuid4" json:"id"`
	Name        string `gorm:"not null;unique;index" validate:"required,min=3,max=20" json:"name"`
	Description string `json:"description"`
	Key         string `gorm:"not null;unique;index" json:"-"`
	Secret      string `gorm:"not null" validate:"required" json:"-"`
	Scopes      string `gorm:"not null" validate:"required" json:"-"`
	RedirectURI string `gorm:"not null" validate:"required" json:"uri"`
	Type        string `gorm:"not null" validate:"required,client" json:"-"`
}

func (*Client) Authentic

func (client *Client) Authentic(secret string) bool

func (*Client) BeforeCreate

func (client *Client) BeforeCreate(scope *gorm.Scope) error

func (*Client) BeforeSave

func (client *Client) BeforeSave(scope *gorm.Scope) error

func (*Client) DefaultRedirectURI

func (client *Client) DefaultRedirectURI() string

func (*Client) UpdateSecret

func (client *Client) UpdateSecret(secret string) error

type Language

type Language struct {
	Model
	Name    string `gorm:"not null;unique;index" validate:"required,min=3"`
	IsoCode string `gorm:"not null;unique" validate:"required,min=2,max=5"`
}

type Model

type Model struct {
	ID        uint      `gorm:"primary_key" json:"-"`
	CreatedAt time.Time `gorm:"not null" json:"-"`
	UpdatedAt time.Time `json:"-"`
}

type Session

type Session struct {
	Model
	UUID        string `gorm:"not null;unique;index" validate:"omitempty,uuid4" json:"-"`
	User        User   `gorm:"not null" validate:"exists" json:"-"`
	UserID      uint   `gorm:"not null" json:"-"`
	Client      Client `gorm:"not null" validate:"exists" json:"-"`
	ClientID    uint   `gorm:"not null" json:"-"`
	Moment      int64  `gorm:"not null" json:"moment"`
	ExpiresIn   int64  `gorm:"not null;default:0" json:"expires_in"`
	Ip          string `gorm:"not null;index" validate:"required" json:"-"`
	UserAgent   string `gorm:"not null" validate:"required" json:"-"`
	Invalidated bool   `gorm:"not null;default:false"`
	Token       string `gorm:"not null;unique;index" validate:"omitempty,alphanum" json:"token"`
	TokenType   string `gorm:"not null;index" validate:"required,token" json:"token_type"`
	Scopes      string `gorm:"not null" validate:"required,scope" json:"-"`
}

func (*Session) BeforeCreate

func (session *Session) BeforeCreate(scope *gorm.Scope) error

func (*Session) BeforeSave

func (session *Session) BeforeSave(scope *gorm.Scope) error

func (*Session) WithinExpirationWindow

func (session *Session) WithinExpirationWindow() bool

type Tokens

type Tokens interface {
	WithinExpirationWindow()
}

type User

type User struct {
	Model
	UUID               string   `gorm:"not null;unique;index" validate:"omitempty,uuid4" json:"-"`
	PublicId           string   `gorm:"not null;unique;index" json:"public_id"`
	Username           string   `gorm:"not null;unique;index" validate:"required,alphanum,max=60" json:"-"`
	FirstName          string   `gorm:"not null" validate:"required,min=3,max=20" essential:"required,min=3,max=20" json:"first_name"`
	LastName           string   `gorm:"not null" validate:"required,min=3,max=20" essential:"required,min=3,max=20" json:"last_name"`
	Email              string   `gorm:"not null;unique;index" validate:"required,email" essential:"required,email" json:"email"`
	Passphrase         string   `gorm:"not null" validate:"required" essential:"required,min=10" json:"-"`
	Active             bool     `gorm:"not null;default:false" json:"active"`
	Admin              bool     `gorm:"not null;default:false" json:"-"`
	Client             Client   `gorm:"not null" validate:"exists" json:"-"`
	ClientID           uint     `gorm:"not null" json:"-"`
	Language           Language `gorm:"not null" validate:"exists" json:"-"`
	LanguageID         uint     `gorm:"not null" json:"-"`
	TimezoneIdentifier string   `gorm:"not null;default:'GMT'" json:"timezone_identifier"`
	CodeSecret         string   `gorm:"not null" validate:"required" json:"-"`
	RecoverSecret      string   `gorm:"not null" validate:"required" json:"-"`
}

func (*User) Authentic

func (user *User) Authentic(password, passcode string) bool

func (*User) BeforeCreate

func (user *User) BeforeCreate(scope *gorm.Scope) error

func (*User) BeforeSave

func (user *User) BeforeSave(scope *gorm.Scope) error

func (*User) GenerateCodeSecret

func (user *User) GenerateCodeSecret() *otp.Key

func (*User) GenerateRecoverSecret

func (user *User) GenerateRecoverSecret() string

func (*User) UpdatePassword

func (user *User) UpdatePassword(password string) error

Jump to

Keyboard shortcuts

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