identity

package
v0.0.0-...-ba645fd Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, claim Claims) context.Context

Types

type Account

type Account struct {
	ID                    string     `json:"id,omitempty" db:"id"`
	App                   string     `json:"app,omitempty" db:"app"`
	Username              string     `json:"username,omitempty" db:"username"`
	PasswordHash          string     `json:"-" db:"password_hash"`
	FirstName             string     `json:"first_name" db:"first_name"`
	LastName              string     `json:"last_name" db:"last_name"`
	Avatar                string     `json:"avatar,omitempty" db:"avatar"`
	Email                 string     `json:"email,omitempty" db:"email"`
	Mobile                string     `json:"mobile,omitempty" db:"mobile"`
	ExternalID            string     `json:"external_id,omitempty" db:"external_id"`
	IsLockedOut           bool       `json:"is_locked_out,omitempty" db:"is_locked_out"`
	FailedPasswordAttempt int        `json:"failed_password_attempt_count,omitempty" db:"failed_password_attempt_count"`
	Roles                 []string   `json:"roles,omitempty"`
	ClientIP              string     `json:"client_ip,omitempty" db:"client_ip"`
	UserAgent             string     `json:"user_agent,omitempty" db:"user_agent"`
	Extension             string     `json:"extension,omitempty" db:"extension"`
	LastLoginAt           *time.Time `json:"last_login_at,omitempty" db:"last_login_at"`
	CreatedAt             *time.Time `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt             *time.Time `json:"updated_at,omitempty" db:"updated_at"`
}

type AccountServicer

type AccountServicer interface {
	Account(ctx context.Context, accountID string) (*Account, error)
	Accounts(ctx context.Context, opt *FindAccountOptions) ([]*Account, error)
	AccountCount(ctx context.Context, opt *FindAccountOptions) (int, error)
	CreateAccount(ctx context.Context, account *Account) error
	UpdateAccountPassword(ctx context.Context, accountID string, newPassword string) error
	LockAccount(ctx context.Context, app, accountID string) error
	UnlockAccount(ctx context.Context, app, accountID string) error
}

type Claims

type Claims map[string]interface{}

func FromContext

func FromContext(ctx context.Context) (Claims, bool)

type FindAccountOptions

type FindAccountOptions struct {
	ID               string `json:"id" db:"id"`
	ExternalID       string `json:"external_id" db:"external_id"`
	App              string `json:"app" db:"app"`
	Username         string `json:"username" db:"username"`
	Email            string `json:"email,omitempty" db:"email"`
	Mobile           string `json:"mobile,omitempty" db:"mobile"`
	Role             string `json:"role"`
	IsLockedOut      int    `json:"is_locked_out" db:"is_locked_out"`
	Skip             int    `db:"skip"`
	Take             int    `db:"take"`
	SortBy           string `db:"sortby"`
	Sort             string
	CreatedTimeStart *time.Time `db:"created_start_time"`
	CreatedTimeEnd   *time.Time `db:"created_end_time"`
	LoginTimeStart   *time.Time `db:"login_start_time"`
	LoginTimeEnd     *time.Time `db:"login_end_time"`
}

type LoginInfo

type LoginInfo struct {
	GrantType string `json:"grant_type"`
	App       string `json:"app"`
	UserName  string `json:"username"`
	Password  string `json:"password"`
}

type Role

type Role struct {
	ID        string     `json:"id,omitempty" db:"id"`
	App       string     `json:"app,omitempty" db:"app"`
	Name      string     `json:"name,omitempty" db:"name"`
	CreatedAt *time.Time `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"`
}

type RoleServicer

type RoleServicer interface {
	Roles(ctx context.Context) ([]*Role, error)
	CreateRole(ctx context.Context, role *Role) error
	UpdateUserRole(ctx context.Context, app, accountID string, roles []string) error
}

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
	Claims      Claims `json:"claims,omitempty"`
}

type TokenServicer

type TokenServicer interface {
	Token(ctx context.Context, app, accessToken string) (*Token, error)
	DeleteToken(ctx context.Context, app, accessToken string) error
	CreateToken(ctx context.Context, login *LoginInfo) (*Token, error, int)
}

Directories

Path Synopsis
delivery

Jump to

Keyboard shortcuts

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