db

package
v0.0.0-...-6fcdc86 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExists = errors.New("already exists")
View Source
var ErrNotFound = errors.New("not found")

Functions

func ValidateUsername

func ValidateUsername(username string) bool

Types

type Action

type Action rune
const (
	Read  Action = 'R'
	Write Action = 'W'
)

type Handle

type Handle struct {
	GetCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)
	// contains filtered or unexported fields
}

func Open

func Open(dir string) (*Handle, error)

func (*Handle) RTxn

func (db *Handle) RTxn() *RTxn

func (*Handle) Txn

func (db *Handle) Txn() *Txn

type Policy

type Policy struct {
	Verb   Verb
	Action Action
	Name   string
	Users  []string
	Paths  []string
}

type RTxn

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

func (*RTxn) Complete

func (tx *RTxn) Complete()

func (*RTxn) FetchAllPolicies

func (tx *RTxn) FetchAllPolicies() []Policy

func (*RTxn) FetchAllUsers

func (tx *RTxn) FetchAllUsers() []User

func (*RTxn) FindUser

func (tx *RTxn) FindUser(username string) (user User, found bool)

func (*RTxn) GetPolicies

func (tx *RTxn) GetPolicies(path string, username string, action Action) []Policy

func (*RTxn) NumUsers

func (tx *RTxn) NumUsers() int

type Txn

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

func (*Txn) AddUser

func (tx *Txn) AddUser(u *User) error

func (*Txn) Complete

func (tx *Txn) Complete()

func (*Txn) DeleteAccessPolicy

func (tx *Txn) DeleteAccessPolicy(name string) error

func (*Txn) DeleteUser

func (tx *Txn) DeleteUser(username string) error

func (*Txn) FindUser

func (tx *Txn) FindUser(username string) (user User, found bool)

func (*Txn) NumUsers

func (tx *Txn) NumUsers() int

func (*Txn) PutAccessPolicy

func (tx *Txn) PutAccessPolicy(p *Policy) error

func (*Txn) UpdateUser

func (tx *Txn) UpdateUser(username string, f func(u *User)) error

type User

type User struct {
	Username string
	Password []byte
	Chroot   string
	Admin    bool
}

type Verb

type Verb string
const (
	Allow Verb = "ALLOW"
	Deny  Verb = "DENY"
)

Jump to

Keyboard shortcuts

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