authentication

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package authentication uses Casbin(https://github.com/casbin/casbin) to load auth rules from database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

type Authentication interface {
	AddPolicies(rules [][]string) (bool, error)
	AddPoliciesEx(rules [][]string) (bool, error)
	AddPolicy(params ...any) (bool, error)
	RemovePolicy(params ...any) (bool, error)
	RemovePolicies(rules [][]string) (bool, error)
	GetFilteredPolicy(fieldIndex int, fieldValues ...string) [][]string
	GetCasbinEnforcer() *casbin.Enforcer
}

func NewAuthentication

func NewAuthentication(rep repository.Repository) (Authentication, error)

NewAuthentication is constructor for authentication

type CasbinRule

type CasbinRule struct {
	ID    uint   `gorm:"primaryKey;autoIncrement"`
	Ptype string `gorm:"size:16"`
	V0    string `gorm:"size:128;comment:'role keyword'"`
	V1    string `gorm:"size:128;comment:'request path'"`
	V2    string `gorm:"size:256;comment:'request method'"`
	V3    string `gorm:"size:100"`
	V4    string `gorm:"size:100"`
	V5    string `gorm:"size:100"`
}

CasbinRule represents casbin rules

Jump to

Keyboard shortcuts

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