model

package
v0.0.0-...-f020cd4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSqlDB

func GetSqlDB(dataSourceName string) (*sql.DB, error)

Types

type Logg

type Logg struct {
	Timestamp      time.Time `json:"timestamp"`
	Resource_name  string    `json:"resource_name"`
	Resource_param string    `json:"resource_param"`
	User_id        string    `json:"user_id"` // foreign key with user table
	Username       string    `json:"username"`
	Access_granted bool      `json:"access_granted"`
}

type Permission

type Permission struct {
	Resource_name string `json:"resource_name"`
	Role_code     int    `json:"role_code"` // foreign key with role table
	Owner_only    bool   `json:"owner_only"`
}

type Role

type Role struct {
	Code  int    `json:"code"`
	Label string `json:"label"`
}

type SqlContext

type SqlContext struct {
	Db *sql.DB
	// contains filtered or unexported fields
}

func GetSqlContext

func GetSqlContext(dataSourceName string, initDB bool) (SqlContext, error)

func (*SqlContext) CreateInitialAdmin

func (s *SqlContext) CreateInitialAdmin() error

func (*SqlContext) CreateInitialPermissions

func (s *SqlContext) CreateInitialPermissions() error

func (*SqlContext) CreateInitialRoles

func (s *SqlContext) CreateInitialRoles() error

func (*SqlContext) CreateLog

func (a *SqlContext) CreateLog(logs Logg) (Logg, error)

func (*SqlContext) CreatePermission

func (a *SqlContext) CreatePermission(permission Permission) (Permission, error)

func (*SqlContext) CreateRole

func (a *SqlContext) CreateRole(role Role) (Role, error)

func (*SqlContext) CreateTables

func (s *SqlContext) CreateTables()

func (*SqlContext) CreateToken

func (a *SqlContext) CreateToken(user User, expire_in time.Duration) (interface{}, error)

func (*SqlContext) CreateUser

func (a *SqlContext) CreateUser(username, lastname, firstname, email, password string, role_id int) (User, error)

func (*SqlContext) DeletePermission

func (a *SqlContext) DeletePermission(resourceName string, roleCode int) error

func (*SqlContext) DropTables

func (s *SqlContext) DropTables()

func (*SqlContext) GetLog4Period

func (a *SqlContext) GetLog4Period(date1, date2 time.Time) ([]Logg, error)

func (*SqlContext) GetLogs

func (a *SqlContext) GetLogs() ([]Logg, error)

func (*SqlContext) GetPermission

func (a *SqlContext) GetPermission(resource_name string, role_code int) (Permission, error)

func (*SqlContext) GetPermissions

func (a *SqlContext) GetPermissions() ([]Permission, error)

func (*SqlContext) GetRole

func (a *SqlContext) GetRole(code int) (Role, error)

func (*SqlContext) GetRoles

func (a *SqlContext) GetRoles() ([]Role, error)

func (*SqlContext) GetToken

func (a *SqlContext) GetToken(tokenvalue string) (Token, error)

func (*SqlContext) GetUser

func (a *SqlContext) GetUser(id string) (User, error)

func (*SqlContext) GetUserByCredentials

func (a *SqlContext) GetUserByCredentials(username, password string) (User, error)

func (*SqlContext) GetUsers

func (a *SqlContext) GetUsers() ([]User, error)

func (*SqlContext) InitBDD

func (s *SqlContext) InitBDD()

func (*SqlContext) InitTables

func (s *SqlContext) InitTables()

func (*SqlContext) IsAuthorized4Token

func (a *SqlContext) IsAuthorized4Token(tokenValue, resourceName, resourceId string) error

func (*SqlContext) IsPermitted4User

func (a *SqlContext) IsPermitted4User(userRole Role, userId, username, resourceName, resourceParam string) bool

func (*SqlContext) PutUser

func (a *SqlContext) PutUser(id, lastname, firstname, email, password string) (User, error)

func (*SqlContext) UnactivateUser

func (a *SqlContext) UnactivateUser(id string) error

type Token

type Token struct {
	Token      string    `json:"token"`
	Expires_in time.Time `json:"expire_in"`
	User_id    string    `json:"user_id"` // foreign key with user table
}

func (*Token) IsValid

func (a *Token) IsValid() bool

type User

type User struct {
	Id        string    `json:"id"`
	Username  string    `json:"username"`
	Lastname  string    `json:"lastname"`
	Firstname string    `json:"firstname"`
	Email     string    `json:"email"`
	Password  []byte    `json:"password"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Activated bool      `json:"activated"`
	Role_id   int       `json:"role_id"` //foreign key with role table
}

Jump to

Keyboard shortcuts

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