Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migrations ¶
func Migrations()
Migrations creates data tables and records for admin user, base client, groups and abilities
Types ¶
type APIMessage ¶
type APIMessage struct {
Message string `json:"message"`
}
type AuthUser ¶
type AuthUser struct { Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` ClientSecret string `json:"client_secret"` }
AuthUser struct has the information to be use when an user try to authenticate
type Client ¶
type Client struct { ID uint CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Name string `json:"name"` ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` Groups []Group `gorm:"many2many:client_groups;" json:"groups"` Abilities []Ability `gorm:"many2many:ability_clients;" json:"abilities"` }
func (*Client) GenerateKeys ¶
func (c *Client) GenerateKeys()
type Group ¶
type Group struct { ID uint CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Name string `json:"name"` Description string `json:"description"` Users []User `gorm:"many2many:user_groups;" json:"users"` Clients []Client `gorm:"many2many:client_groups;" json:"clients"` }
func (Group) HasAbility ¶
HasAbility checks if group has a specific ability
type NewAbility ¶
type NewAbility struct {
Name string `json:"name"`
}
type NewUser ¶
type NewUser struct { Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` }
NewUser struct has the information to create a new user
type User ¶
type User struct { ID uint CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Name string `json:"name"` Email string `json:"email"` EncryptPassword string `json:"-"` Groups []Group `gorm:"many2many:user_groups;" json:"groups"` }
User keep user information like email and password for authentication
func (User) Authenticate ¶
Authenticate check if email and password are correct and if have authorization for use the client
func (User) HasAbility ¶
HasAbility checks if user has a specific ability
func (User) HasClientAccess ¶
HasClientAccess checks if user has authorization to authenticate in a client
func (*User) SetPassword ¶
SetPassword sets the user password after encrypt it
Click to show internal directories.
Click to hide internal directories.