auth

package module
v0.0.0-...-eca36f1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 12 Imported by: 0

README

auth

General Auth Tools for APIs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIAuth

func APIAuth(ctx context.Context, req *AuthRequest) (sessid string, err error)

@API @PATH: /auth

func AddGroup

func AddGroup(gname string) (err error)

func AddPerm

func AddPerm(name string) (err error)

func AddPermToGroup

func AddPermToGroup(g string, p string) (err error)

func AddUser

func AddUser(u *User) (err error)

func AddUserToGroup

func AddUserToGroup(u string, g string) (err error)

func Auth

func Auth(username, password string) (sessid string, err error)

func Build

func Build(r *gin.Engine)

func DisableUser

func DisableUser(u string) (err error)

func EnableUser

func EnableUser(u string) (err error)

func GetPerm

func GetPerm(c *gin.Context) string

func Init

func Init(c *Config) (err error)

func MDSession

func MDSession(ctx *gin.Context)

func Prepare

func Prepare() (err error)

func RemGroup

func RemGroup(gname string) (err error)

func RemPerm

func RemPerm(name string) (err error)

func RemovePermFromGroup

func RemovePermFromGroup(g string, p string) (err error)

func RemoveUserFromGroup

func RemoveUserFromGroup(u string, g string) (err error)

func SetUserPass

func SetUserPass(u string, p string) (err error)

Types

type AuthRequest

type AuthRequest struct {
	Username string
	Password string
}

@API

type Config

type Config struct {
	Dburl      string
	Dbdriver   string
	CookieName string
}

type Group

type Group struct {
	Id    uint
	Name  string
	Perms []*Perm `gorm:"many2many:group_perms;"`
}

type Perm

type Perm struct {
	Id   uint
	Name string
}

type Session

type Session struct {
	Id       string
	Perms    string
	Username string
}

func Sess

func Sess(id string) (ret *Session, err error)

func (*Session) HasPerm

func (s *Session) HasPerm(p string) bool

type User

type User struct {
	Id       uint
	Username string
	Enabled  *bool
	Name     string
	Email    string
	Hash     string
	Groups   []*Group `gorm:"many2many:user_groups;"`
}

Jump to

Keyboard shortcuts

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