Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

type Authorizer struct {
	// contains filtered or unexported fields
}

Authorizer an RBAC authorizer

func NewAuthorizer

func NewAuthorizer(conf string, db *gorm.DB, userHandler func(r *http.Request) (string, error)) (*Authorizer, error)

NewAuthorizer returns the authorizer

func (*Authorizer) Auth

func (a *Authorizer) Auth() gin.HandlerFunc

Auth returns the authorizer handler

func (*Authorizer) LoadPolicy

func (a *Authorizer) LoadPolicy() error

LoadPolicy load the policy from the adaptor

type Permission

type Permission struct {
	gorm.Model
	RoleID   uint
	Role     *Role `gorm:"foreignKey:RoleID"`
	Resource string
	Method   string
}

Permission ...

func (*Permission) RoleName

func (p *Permission) RoleName() (name string)

RoleName get role name of current permission

func (*Permission) TableName

func (p *Permission) TableName() string

TableName return the table name

type Role

type Role struct {
	gorm.Model
	Name  string
	Users []*User `gorm:"many2many:auth_user_roles"`
}

Role ...

func (*Role) TableName

func (r *Role) TableName() string

TableName return the table name

type User

type User struct {
	gorm.Model
	Email string
}

User ...

func (*User) TableName

func (r *User) TableName() string

TableName return the table name

type UserRoles

type UserRoles struct {
	gorm.Model
	RoleID uint
	UserID uint
}

UserRoles ...

func (*UserRoles) TableName

func (r *UserRoles) TableName() string

TableName return the table name

Jump to

Keyboard shortcuts

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