pitchfork

package
v1.4.6-0...-a5bad84 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 65 Imported by: 9

Documentation

Index

Constants

View Source
const (
	StatusOK           = 200
	StatusUnauthorized = 401
)
View Source
const (
	GROUP_STATE_APPROVED = "approved"
	GROUP_STATE_BLOCKED  = "blocked"
)
View Source
const CRLF = "\r\n"
View Source
const ERR_UNKNOWN_CMDPFX = "Unknown command: "
View Source
const File_Perms_Dir os.FileMode = 0700
View Source
const File_Perms_File os.FileMode = 0600
View Source
const JWT_INVALID_CACHE_MAX = 512
View Source
const Msg_sep = "/"

The separator between the message IDs

View Source
const PAGER_PERPAGE = 10

Constants

View Source
const TOKEN_EXPIRATIONMINUTES = 20

Default Token expiration time

View Source
const Wiki_Perms_Export os.FileMode = 0755

Variables

View Source
var AppCopyright = ""
View Source
var AppName = "Pitchfork"
View Source
var AppVersion = "unconfigured"
View Source
var AppWebsite = ""
View Source
var CheckTwoFactor = true

Whether we verify 2FA tokens or not (--disabletwofactor)

View Source
var Debug = false
View Source
var ErrFilePathExists = errors.New("Path already exists")
View Source
var ErrLoginIncorrect = errors.New("Login incorrect")
View Source
var ErrNoRows = sql.ErrNoRows
View Source
var (
	Err_NoPassword = errors.New("Please actually provide a password")
)
View Source
var IPtrk chan IPtrkS
View Source
var IPtrk_Max int
View Source
var IPtrk_done chan bool
View Source
var IPtrk_running bool
View Source
var LogLocation = false
View Source
var MainMenu = NewPfMenu([]PfMEntry{
	{"user", user_menu, 0, -1, nil, PERM_NONE, "User commands"},
	{"group", group_menu, 0, -1, nil, PERM_USER, "Group commands"},
	{"ml", ml_menu, 0, -1, nil, PERM_USER, "Mailing List commands"},
	{"system", system_menu, 0, -1, nil, PERM_NONE, "System commands"},
})
View Source
var Msg_Props = "" +
	"SELECT msg.id, msg.path, msg.depth, msg.title, " +
	"msg.plaintext, msg.html, msg.entered, m.ident, m.descr, " +
	"msg_read.entered " +
	"FROM msg_messages msg " +
	"INNER JOIN member m ON msg.member = m.ident " +
	"LEFT OUTER JOIN msg_read ON msg.id = msg_read.id AND msg_read.member = $1"
View Source
var Started = time.Now().UTC()

Functions

func AppVersionStr

func AppVersionStr() string

func App_db_upgrade

func App_db_upgrade() (err error)

func CheckPWRules

func CheckPWRules(ctx PfCtx, password string) (err error)

func Chk_ident

func Chk_ident(name string, in string) (out string, err error)

func CopyDir

func CopyDir(ctx PfCtx, verbose bool, source string, dest string) (err error)

func CopyFile

func CopyFile(ctx PfCtx, verbose bool, source string, dest string) (err error)

func CreateKey

func CreateKey(length int) (out string, err error)

func DB_Init

func DB_Init(verbosity bool)

func DB_IsPQErrorConstraint

func DB_IsPQErrorConstraint(err error) bool

* Check for a Unique Violation * * "duplicate key value violates unique constraint"

func DB_SetAppVersion

func DB_SetAppVersion(ver int)

func Daemon

func Daemon(nochdir int, noclose int) (err error)

func Dbg

func Dbg(message string)

func DbgA

func DbgA(off int, format string, a ...interface{})

func Dbgf

func Dbgf(format string, a ...interface{})

func DetailCheck

func DetailCheck(detail string) (err error)

func DetailType

func DetailType(detail string) (out string)

func Diff_Out

func Diff_Out(ctx PfCtx, a string, b string)

func EncodeKey

func EncodeKey(secret string) (out string)

func Err

func Err(message string)

func ErrA

func ErrA(off int, format string, a ...interface{})

* Logging - centralized and to avoid importing log everywhere * Might extend this with extra params to make per-context tracing possible

func ErrIsDisconnect

func ErrIsDisconnect(err error) bool

func ErrIsUnknownCommand

func ErrIsUnknownCommand(err error) bool

func Errf

func Errf(format string, a ...interface{})

func File_ChildPagesMax

func File_ChildPagesMax(ctx PfCtx, path string) (total int, err error)

func File_ModOpts

func File_ModOpts(ctx PfCtx, cmdpfx string, path_root string, web_root string)

func File_RevisionMax

func File_RevisionMax(ctx PfCtx, path string) (total int, err error)

func File_Update

func File_Update(ctx PfCtx, path string, desc string, changemsg string, file *os.File) (err error)

Called directly by UI and also CLI (TODO)

func File_add_file

func File_add_file(ctx PfCtx, path string, description string, file io.Reader) (err error)

* Used by the UI directly and also CLI

func File_add_localfile

func File_add_localfile(ctx PfCtx, args []string) (err error)

* !! CLI only !! * * Don't call through UI as it takes a local filename, don't want to read /etc/passwd ;) * * This is also why the function is marked as PERM_SYS_ADMIN

func File_add_url

func File_add_url(ctx PfCtx, args []string) (err error)

func File_delete

func File_delete(ctx PfCtx, path string, children bool) (cnt int, err error)

func File_menu

func File_menu(ctx PfCtx, args []string) (err error)

func File_path_is_dir

func File_path_is_dir(path string) (is_dir bool)
func File_search(ctx PfCtx, pathroot string, c chan PfSearchResult, search string, abort <-chan bool) (err error)

func Fmt_Time

func Fmt_Time(t time.Time) string

func Fullname_to_ident

func Fullname_to_ident(name string) (out string, err error)

func GetPID

func GetPID() (pid string)

func Group_FileMod

func Group_FileMod(ctx PfCtx)

func Group_WikiMod

func Group_WikiMod(ctx PfCtx)

func HE

func HE(str string) string

func HEB

func HEB(str string) template.HTML

func HashIt

func HashIt(input string) (hash string)

func Hex

func Hex(data []byte) string

func Image_resize

func Image_resize(file io.Reader, maxsize string) (bits []byte, err error)

func Iptrk_count

func Iptrk_count(ip string) (limited bool)

func Iptrk_reset

func Iptrk_reset(ip string) (ret bool)

func Iptrk_start

func Iptrk_start(max int, timeoutchk time.Duration, expire string)

func Iptrk_stop

func Iptrk_stop()

func IsTrue

func IsTrue(val string) (b bool)

IsTrue() defaults to false if the string is not known

func JwtInv_start

func JwtInv_start(timeoutchk time.Duration)

func JwtInv_stop

func JwtInv_stop()

func JwtInv_test_cache_len

func JwtInv_test_cache_len() int

Hooks for test code

func JwtInv_test_expire

func JwtInv_test_expire() (before int, after int, err error)

func JwtInv_test_iscached

func JwtInv_test_iscached(tok string) (ok bool)

func JwtInv_test_list_len

func JwtInv_test_list_len() int

func Jwt_invalidate

func Jwt_invalidate(tok string, claims JWTClaimI)

func Jwt_isinvalidated

func Jwt_isinvalidated(tok string, claims JWTClaimI) (invalid bool)

func LanguageSkillList

func LanguageSkillList() (languageskill []string)

func ListKeys

func ListKeys(ctx PfCtx, keyset map[[16]byte][]byte, gr_name string, ml_name string) (err error)

func Log

func Log(message string)

func LogA

func LogA(off int, format string, a ...interface{})

func LogLoc

func LogLoc(off int, pfx string) string

func Logf

func Logf(format string, a ...interface{})

func Mail

func Mail(ctx PfCtx, src_name string, src string, dst_name string, dst string, prefix bool, subject string, body string, regards bool, footer string, sysfooter bool) (err error)

Wrapper around the real mailA() function so we can handle errors in a single place

func MailM

func MailM(ctx PfCtx, src_name string, src string, dst_name []string, dst []string, prefix bool, subject string, body string, regards bool, footer string, sysfooter bool) (err error)

func Mail_PasswordChanged

func Mail_PasswordChanged(ctx PfCtx, email PfUserEmail) (err error)

func Mail_VerifyEmail

func Mail_VerifyEmail(ctx PfCtx, email PfUserEmail, verifycode string) (err error)

func Ml_addv

func Ml_addv(ctx PfCtx, grp PfGroup, ml_name string, descr string, member_only bool, can_add_self bool, automatic bool) (err error)

Group must be selected with PERM_GROUP_ADMIN

func Msg_Create

func Msg_Create(ctx PfCtx, path string, title string, plaintext string, notify bool) (newpath string, err error)

func Msg_Create_With_User

func Msg_Create_With_User(ctx PfCtx, user PfUser, path string, title string, plaintext string, notify bool) (newpath string, err error)

func Msg_MarkNew

func Msg_MarkNew(ctx PfCtx, msg PfMessage) (err error)

func Msg_MarkSeen

func Msg_MarkSeen(ctx PfCtx, msg PfMessage) (err error)

func Msg_ModOpts

func Msg_ModOpts(ctx PfCtx, cmdpfx string, path_root string, web_root string, thread_depth int, title string)

func Msg_ModPathDepth

func Msg_ModPathDepth(ctx PfCtx) (depth int)

* The Module Root's should never have a trailing '/' * Hence why we do not substract here compared to Msg_PathDepth()

func Msg_PathDepth

func Msg_PathDepth(ctx PfCtx, path string) (depth int)

* Calculate the depth of a path * A depth of 0 is the root (/)

func Msg_PathValid

func Msg_PathValid(ctx PfCtx, path *string) (err error)

We ignore effective root for this as that should always be valid

func Msg_Post

func Msg_Post(ctx PfCtx, path string, title string, plaintext string) (newpath string, err error)

func Msg_menu

func Msg_menu(ctx PfCtx, args []string) (err error)

func NI64

func NI64(n int64) sql.NullInt64

func NewPfUserEmailI

func NewPfUserEmailI() interface{}

func NormalizeBoolean

func NormalizeBoolean(val string) string

func OAuth2_AccessToken_New

func OAuth2_AccessToken_New(ctx PfCtx, client_id string, scope string) (tok string, err error)

func OAuth2_AuthToken_New

func OAuth2_AuthToken_New(ctx PfCtx, o OAuth_Auth) (tok string, err error)

func ObjFunc

func ObjFunc(obj ObjFuncI, fun string, params ...interface{}) (result []reflect.Value, err error)

func ObjFuncIface

func ObjFuncIface(obj ObjFuncI, fun string, params ...interface{}) (iface interface{}, err error)

func ObjFuncStr

func ObjFuncStr(obj ObjFuncI, fun string, params ...interface{}) (str string, err error)

func ObjPermCheck

func ObjPermCheck(ctx PfCtx, obj ObjFuncI, ptype PType, f PTypeField) (ok bool, allowedit bool, err error)

func OutA

func OutA(format string, a ...interface{})

Silly golang log functions just ignore errors... thus do our own

func OutEsc

func OutEsc(str string) (nstr string)

* Encode non-ASCII chars in URL-encoded format * This to make sure control-codes etc do not end up in output * * We encode in URL-encoded format, but we do not escape HTML chars * anything rendering those should handle that part properly. * * Note: this might not be unicode friendly

func PathOffset

func PathOffset(file_path string, dir_path string) (count int)

func PfRender

func PfRender(markdown string, toconly bool) (html string)

func PfType

func PfType(f reflect.StructField, v reflect.Value, doignore bool) (ttype string, dorecurse bool, compound bool)

* Get the datatype from either the forced version * or the actual type of the field using reflection * * If 'doignore' is set return 'ignore'

func Pw_checkweak

func Pw_checkweak(password string) (isweak bool)

func Pw_checkweak_load

func Pw_checkweak_load() (err error)

func Rand_number

func Rand_number(max int) int

func SearchResult

func SearchResult(c chan PfSearchResult, source string, title string, link string, summary string)

func SearcherRegister

func SearcherRegister(f PfSearcherI)

func SetAppDetails

func SetAppDetails(name string, ver string, copyright string, website string)

func SetUID

func SetUID(username string) (err error)

func Setup

func Setup(toolname string, confroot string, verbosedb bool, app_schema_version int) (err error)

func SetupTranslation

func SetupTranslation() (err error)

func SortKeys

func SortKeys(tbl map[string]string) (keys []string)

func SplitArgs

func SplitArgs(str string) (args []string)

Parse the string (obeying quoting)

func Starts

func Starts()

Start background services

func Stops

func Stops()

Should be deferred Starts() call

func StorePID

func StorePID(filename string, pid string)

func StructDetails

func StructDetails(ctx PfCtx, obj interface{}, field string, opts StructDetails_Options) (ftype string, fname string, fvalue string, err error)

func StructDetailsA

func StructDetailsA(ctx PfCtx, obj interface{}, field string, opts StructDetails_Options) (ftype string, fname string, fvalue string, err error)

func StructFetch

func StructFetch(obj interface{}, table string, params []string, matches []string) (err error)

func StructFetchA

func StructFetchA(obj interface{}, table string, join string, params []string, matches []string, order string, notfoundok bool) (err error)

func StructFetchFields

func StructFetchFields(obj interface{}, table string, q *string, ifs *[]interface{}) (err error)

func StructFetchMulti

func StructFetchMulti(newobject func() interface{}, table string, join string, andor DB_AndOr, params []string, matchopts []DB_Op, matches []interface{}, order string, offset int, limit int) (objs []interface{}, err error)

func StructFetchStore

func StructFetchStore(obj interface{}, ifs []interface{}, ifs_n *int) (err error)

func StructFetchWhere

func StructFetchWhere(qi string, table string, join string, andor DB_AndOr, params []string, matchopts []DB_Op, matches []interface{}, order string) (q string, vals []interface{})

func StructFieldMod

func StructFieldMod(op StructOp, fname string, f reflect.StructField, v reflect.Value, value interface{}) (err error)

func StructMod

func StructMod(op StructOp, obj interface{}, field string, value interface{}) (err error)

func StructModA

func StructModA(op StructOp, obj interface{}, field string, value interface{}) (done bool, err error)

func StructNameObj

func StructNameObj(obj interface{}) string

func StructNameObjTrail

func StructNameObjTrail(objtrail []interface{}) (oname string)

func StructNameT

func StructNameT(t reflect.Type) string

func StructPermCheck

func StructPermCheck(ctx PfCtx, ptype PType, objtrail []interface{}, f PTypeField) (ok bool, allowedit bool, err error)

func StructRecurse

func StructRecurse(v reflect.Value) interface{}

* Check CanAddr() so that we do a recurse while * we can with ability to set, but recurse otherwise * in readonly version

func StructReflect

func StructReflect(obj interface{}) (s reflect.Type, va reflect.Value)

func StructTag

func StructTag(obj interface{}, field string, tag string) (val string, err error)

func StructTagA

func StructTagA(obj interface{}, field string, tag string) (val string, err error)

func StructVars

func StructVars(ctx PfCtx, obj interface{}, ptype PType, doignore bool) (vars map[string]string, err error)

* Return all fields of a struct that can be retrieved or modified

func StructVarsA

func StructVarsA(ctx PfCtx, objtrail []interface{}, obj interface{}, ptype PType, doignore bool, vars map[string]string) (err error)

func System_AuditMax

func System_AuditMax(search string, user_name string, gr_name string) (total int, err error)

func System_SharedFile

func System_SharedFile(thefile string) (fn string, err error)

func System_adduser

func System_adduser(username string, password string) (err error)

setup only

func System_db_cleanup

func System_db_cleanup() (err error)

func System_db_setup

func System_db_setup() (err error)

func System_db_test_setup

func System_db_test_setup() (err error)

func System_db_upgrade

func System_db_upgrade() (err error)

func System_findfile

func System_findfile(subdir string, name string) (fn string)

func System_setpassword

func System_setpassword(username string, password string) (err error)

setup only

func Template_FuncAdd

func Template_FuncAdd(name string, f interface{})

func Template_Get

func Template_Get() *template.Template

func Template_Load

func Template_Load() (err error)

func ThisFunc

func ThisFunc() string

func ToNullInt64

func ToNullInt64(v int64) sql.NullInt64

func ToNullString

func ToNullString(s string) sql.NullString

func ToString

func ToString(v interface{}) (str string)

func ToUTF8

func ToUTF8(iso8859_1_buf []byte) string

func Token_Parse

func Token_Parse(tok string, ttype string, claims JWTClaimI) (expsoon bool, err error)

func TrackStart

func TrackStart() time.Time

func TrackTime

func TrackTime(start time.Time, name string) (elapsed time.Duration)

func TranslateObj

func TranslateObj(ctx PfCtx, objtrail []interface{}, label string) string

func TwoFactorTypes

func TwoFactorTypes() (types keyval.KeyVals)

func URL_Append

func URL_Append(url1 string, url2 string) (url string)

Append two parts of a URL together, adding a '/' in the middle where needed

func URL_EnsureSlash

func URL_EnsureSlash(url string) string

Ensure that a URL ends in a slash

func User_Email_Verify

func User_Email_Verify(ctx PfCtx, username string, emailaddr string) (err error)

func User_merge

func User_merge(ctx PfCtx, u_new string, u_old string, err_ error) (err error)

Called with Tx held

func User_new

func User_new(ctx PfCtx, username string, email string, bio_info string, affiliation string, descr string) (err error)

func VersionText

func VersionText() string

func Where

func Where(off int) string

func Wiki_ChildPagesMax

func Wiki_ChildPagesMax(ctx PfCtx, path string) (total int, err error)

func Wiki_ModOpts

func Wiki_ModOpts(ctx PfCtx, cmdpfx string, path_root string, web_root string)

func Wiki_RevisionMax

func Wiki_RevisionMax(ctx PfCtx, path string) (total int, err error)

func Wiki_SearchMax

func Wiki_SearchMax(ctx PfCtx, search string) (total int, err error)

func Wiki_Title

func Wiki_Title(path string) (title string)

func Wiki_TitleComponent

func Wiki_TitleComponent(title string) string

func Wiki_menu

func Wiki_menu(ctx PfCtx, args []string) (err error)
func Wiki_search(ctx PfCtx, pathroot string, c chan PfSearchResult, search string, abort <-chan bool) (err error)

func YesNo

func YesNo(b bool) (val string)

Types

type DB_AndOr

type DB_AndOr int
const (
	DB_OP_AND DB_AndOr = iota
	DB_OP_OR
)

type DB_Op

type DB_Op int
const (
	DB_OP_LIKE DB_Op = iota
	DB_OP_ILIKE
	DB_OP_EQ
	DB_OP_NE
	DB_OP_LE
	DB_OP_GE
)

type IPtrkEntry

type IPtrkEntry struct {
	Blocked bool
	IP      string
	Count   int
	Entered time.Time
	Last    time.Time
}

func IPtrk_List

func IPtrk_List(ctx PfCtx) (ts []IPtrkEntry, err error)

type IPtrkS

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

type JWTClaimI

type JWTClaimI interface {
	jwt.Claims
	GetJWTClaims() *JWTClaims
}

type JWTClaims

type JWTClaims struct {
	jwt.StandardClaims
}

func (*JWTClaims) GetJWTClaims

func (jwtc *JWTClaims) GetJWTClaims() *JWTClaims

type MsgType

type MsgType uint
const (
	MSGTYPE_SECTION MsgType = iota
	MSGTYPE_THREAD
	MSGTYPE_MESSAGE
)

func Msg_PathType

func Msg_PathType(ctx PfCtx, path string) MsgType

type OAuth2Claims

type OAuth2Claims struct {
	JWTClaims
	ClientID string `json:"oa_client_id"`
	Scope    string `json:"oa_scope"`
	RType    string `json:"oa_rtype,omitempty"`
	Redirect string `json:"oa_redirect,omitempty"`
}

func OAuth2_AuthToken_Check

func OAuth2_AuthToken_Check(tok string) (claims *OAuth2Claims, err error)

type OAuth_Auth

type OAuth_Auth struct {
	ClientID string `label:"Client ID" pfset:"nobody" pfget:"none"`
	Scope    string `label:"Scope" pfset:"nobody" pfget:"none"`
	RType    string `label:"Request Type" pfset:"nobody" pfget:"none"`
	Redirect string `label:"Redirect URL" pfset:"nobody" pfget:"none"`
	Auth     string `label:"Authorize" pftype:"submit"`
	Deny     string `label:"Deny" pftype:"submit" htmlclass:"deny"`
}

type ObjFuncI

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

func ObjHasFunc

func ObjHasFunc(objtrail []interface{}, fun string) (ok bool, obj ObjFuncI)

type PType

type PType int
const (
	PTYPE_CREATE PType = iota /* Create */
	PTYPE_READ                /* Read */
	PTYPE_UPDATE              /* Update */
	PTYPE_DELETE              /* Delete */
)

CRUD

type PTypeField

type PTypeField struct {
	reflect.StructField
}

func PTypeWrap

func PTypeWrap(f reflect.StructField) PTypeField

type Perm

type Perm uint64
const (
	PERM_NOTHING        Perm = 0         /* Nothing / empty permissions */
	PERM_NONE           Perm = 1 << iota /* No access bits needed (unauthenticated) */
	PERM_GUEST                           /* Not authenticated */
	PERM_USER                            /* User (authenticated) */
	PERM_USER_SELF                       /* User when they selected themselves */
	PERM_USER_NOMINATE                   /* User when doing nomination */
	PERM_USER_VIEW                       /* User when just trying to view */
	PERM_GROUP_MEMBER                    /* Member of the group */
	PERM_GROUP_ADMIN                     /* Admin of the group */
	PERM_GROUP_WIKI                      /* Group has Wiki section enabled */
	PERM_GROUP_FILE                      /* Group has File section enabled */
	PERM_GROUP_CALENDAR                  /* Group has Calendar section enabled */
	PERM_SYS_ADMIN                       /* System Administrator */
	PERM_SYS_ADMIN_CAN                   /* Can be a System Administrator */
	PERM_CLI                             /* When CLI is enabled */
	PERM_API                             /* When API is enabled */
	PERM_OAUTH                           /* When OAUTH is enabled */
	PERM_LOOPBACK                        /* Connected from Loopback */
	PERM_HIDDEN                          /* Option is hidden */
	PERM_NOCRUMB                         /* Don't add a crumb for this menu */
	PERM_NOSUBS                          /* No sub menus for this menu entry */
	PERM_NOBODY                          /* Nobody has access */

	/* Application permissions */
	PERM_APP_0
	PERM_APP_1
	PERM_APP_2
	PERM_APP_3
	PERM_APP_4
	PERM_APP_5
	PERM_APP_6
	PERM_APP_7
	PERM_APP_8
	PERM_APP_9
)

func (Perm) String

func (perm Perm) String() (str string)

type PfAppPermsI

type PfAppPermsI func(ctx PfCtx, what string, perms Perm) (final bool, ok bool, err error)

type PfAudit

type PfAudit struct {
	Member    string
	What      string
	UserName  string
	GroupName string
	Remote    string
	Entered   time.Time
}

func System_AuditList

func System_AuditList(search string, user_name string, gr_name string, offset int, max int) (audits []PfAudit, err error)

type PfConfig

type PfConfig struct {
	Conf_root       string       ``                  /* From command line option or default setting */
	File_roots      []string     `json:"file_roots"` /* Where we look for files */
	Var_root        string       `json:"var_root"`   /* Where variable files are stored */
	Tmp_roots       []string     `json:"tmp_roots"`  /* Templates */
	LogFile         string       `json:"logfile"`    /* Where to write our log file (with logrotate support) */
	Token_prv       interface{}  ``
	Token_pub       interface{}  ``
	UserAgent       string       `json:"useragent"`
	CSS             []string     `json:"css"`
	Javascript      []string     `json:"javascript"`
	CSP             string       `json:"csp"`
	XFF             []string     `json:"xff_trusted_cidr"`
	XFFc            []*net.IPNet ``
	Db_host         string       `json:"db_host"`
	Db_port         string       `json:"db_port"`
	Db_name         string       `json:"db_name"`
	Db_user         string       `json:"db_user"`
	Db_pass         string       `json:"db_pass"`
	Db_ssl_mode     string       `json:"db_ssl_mode"`
	Db_admin_db     string       `json:"db_admin_db"`
	Db_admin_user   string       `json:"db_admin_user"`
	Db_admin_pass   string       `json:"db_admin_pass"`
	Nodename        string       `json:"nodename"`
	Http_host       string       `json:"http_host"`
	Http_port       string       `json:"http_port"`
	JWT_prv         string       `json:"jwt_key_prv"`
	JWT_pub         string       `json:"jwt_key_pub"`
	Application     interface{}  `json:"application"`
	Username_regexp string       `json:"username_regexp"`
	UserHomeLinks   bool         `json:"user_home_links"`
	SMTP_host       string       `json:"smtp_host"`
	SMTP_port       string       `json:"smtp_port"`
	SMTP_SSL        string       `json:"smtp_ssl"`
	Msg_mon_from    string       `json:"msg_monitor_from"`
	Msg_mon_to      string       `json:"msg_monitor_to"`
	TimeFormat      string       `json:"timeformat"`
	DateFormat      string       `json:"dateformat"`
	PW_WeakDicts    []string     `json:"pw_weakdicts"`
	CFG_UserMinLen  string       `json:"username_min_length"`
	CFG_UserExample string       `json:"username_example"`
	TransDefault    string       `json:"translation_default"`
	TransLanguages  []string     `json:"translation_languages"`
}
var Config PfConfig

func (*PfConfig) GetAppConfig

func (cfg *PfConfig) GetAppConfig(varname string) (out string)

func (*PfConfig) GetAppConfigBool

func (cfg *PfConfig) GetAppConfigBool(varname string) (out bool)

func (*PfConfig) Load

func (cfg *PfConfig) Load(toolname string, confroot string) (err error)

func (*PfConfig) Token_LoadPrv

func (cfg *PfConfig) Token_LoadPrv() (err error)

func (*PfConfig) Token_LoadPub

func (cfg *PfConfig) Token_LoadPub() (err error)

type PfCreds

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

type PfCtx

type PfCtx interface {
	GetAbort() <-chan bool
	SetAbort(abort <-chan bool)
	StoreCreds() (creds PfCreds)
	RestoreCreds(creds PfCreds)
	SetTx(tx *Tx)
	GetTx() (tx *Tx)
	Err(message string)
	Errf(format string, a ...interface{})
	Log(message string)
	Logf(format string, a ...interface{})
	Dbg(message string)
	Dbgf(format string, a ...interface{})
	Init() (err error)
	SetStatus(code int)
	GetStatus() (code int)
	SetReturnCode(rc int)
	GetReturnCode() (rc int)
	GetLoc() string
	GetLastPart() string
	Become(user PfUser)
	GetToken() (tok string)
	NewToken() (err error)
	LoginToken(tok string) (expsoon bool, err error)
	Login(username string, password string, twofactor string) (err error)
	Logout()
	IsLoggedIn() bool
	IsGroupMember() bool
	IAmGroupAdmin() bool
	IAmGroupMember() bool
	GroupHasWiki() bool
	GroupHasFile() bool
	GroupHasCalendar() bool
	CanBeSysAdmin() bool
	SwapSysAdmin() bool
	IsSysAdmin() bool
	ConvertPerms(str string) (perm Perm, err error)
	IsPerm(perms Perm, perm Perm) bool
	IsPermSet(perms Perm, perm Perm) bool
	CheckPerms(what string, perms Perm) (ok bool, err error)
	CheckPermsT(what string, permstr string) (ok bool, err error)
	TheUser() (user PfUser)
	SelectedSelf() bool
	SelectedUser() (user PfUser)
	SelectedGroup() (grp PfGroup)
	SelectedML() (ml PfML)
	SelectedEmail() (email PfUserEmail)
	SelectedUser2FA() (tfa PfUser2FA)
	HasSelectedUser() bool
	HasSelectedGroup() bool
	HasSelectedML() bool
	SelectMe()
	SelectUser(username string, perms Perm) (err error)
	SelectUser2FA(id int, perms Perm) (err error)
	SelectGroupA(grp PfGroup, gr_name string, perms Perm) (err error)
	SelectGroup(gr_name string, perms Perm) (err error)
	SelectML(ml_name string, perms Perm) (err error)
	SelectEmail(email string) (err error)
	SetModOpts(opts PfModOptsI)
	GetModOpts() (opts interface{})
	PDbgf(what string, perm Perm, format string, a ...interface{})
	Out(txt string)
	Outf(format string, a ...interface{})
	OutLn(format string, a ...interface{})
	SetOutUnbuffered(obj interface{}, fun string)
	OutBuffered(on bool)
	IsBuffered() bool
	Buffered() (o string)
	GetRemote() (remote string)
	SetClient(clientip net.IP, remote string, ua string)
	GetClientIP() net.IP
	GetUserAgent() (string, string, string)
	SelectObject(obj *interface{})
	SelectedObject() (obj *interface{})
	GetLanguage() string
	SetLanguage(name string)
	GetTfunc() i18n.TranslateFunc

	NewUser() (user PfUser)
	NewUserI() (i interface{})
	NewGroup() (user PfGroup)
	NewGroupI() (i interface{})

	/* Menu Overrides */
	MenuOverride(menu *PfMenu)

	/* menu.go */
	Menu(args []string, menu PfMenu) (err error)
	WalkMenu(args []string) (menu *PfMEntry, err error)
	Cmd(args []string) (err error)
	CmdOut(cmd string, args []string) (msg string, err error)
	Batch(filename string) (err error)

	/* appdata */
	SetAppData(data interface{})
	GetAppData() interface{}
}

Context Interface, allowing it to be extended

func NewPfCtx

func NewPfCtx(newuser PfNewUserI, newgroup PfNewGroupI, menuoverride PfMenuI, appperms PfAppPermsI, postbecome PfPostBecomeI) PfCtx

type PfCtxS

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

func (*PfCtxS) Batch

func (ctx *PfCtxS) Batch(filename string) (err error)

func (*PfCtxS) Become

func (ctx *PfCtxS) Become(user PfUser)

func (*PfCtxS) Buffered

func (ctx *PfCtxS) Buffered() (o string)

func (*PfCtxS) CanBeSysAdmin

func (ctx *PfCtxS) CanBeSysAdmin() bool

func (*PfCtxS) CheckPerms

func (ctx *PfCtxS) CheckPerms(what string, perms Perm) (ok bool, err error)

* Multiple permissions can be specified * thus test from least to most to see * if any of them allows access

func (*PfCtxS) CheckPermsT

func (ctx *PfCtxS) CheckPermsT(what string, permstr string) (ok bool, err error)

func (*PfCtxS) Cmd

func (ctx *PfCtxS) Cmd(args []string) (err error)

func (*PfCtxS) CmdOut

func (ctx *PfCtxS) CmdOut(cmd string, args []string) (msg string, err error)

func (*PfCtxS) ConvertPerms

func (ctx *PfCtxS) ConvertPerms(str string) (perm Perm, err error)

func (*PfCtxS) Dbg

func (ctx *PfCtxS) Dbg(message string)

func (*PfCtxS) Dbgf

func (ctx *PfCtxS) Dbgf(format string, a ...interface{})

func (*PfCtxS) Err

func (ctx *PfCtxS) Err(message string)

func (*PfCtxS) Errf

func (ctx *PfCtxS) Errf(format string, a ...interface{})

func (*PfCtxS) GetAbort

func (ctx *PfCtxS) GetAbort() <-chan bool

func (*PfCtxS) GetAppData

func (ctx *PfCtxS) GetAppData() interface{}

func (*PfCtxS) GetClientIP

func (ctx *PfCtxS) GetClientIP() net.IP

func (*PfCtxS) GetLanguage

func (ctx *PfCtxS) GetLanguage() string

func (*PfCtxS) GetLastPart

func (ctx *PfCtxS) GetLastPart() string

func (*PfCtxS) GetLoc

func (ctx *PfCtxS) GetLoc() string

func (*PfCtxS) GetModOpts

func (ctx *PfCtxS) GetModOpts() (opts interface{})

func (*PfCtxS) GetRemote

func (ctx *PfCtxS) GetRemote() (remote string)

func (*PfCtxS) GetReturnCode

func (ctx *PfCtxS) GetReturnCode() (rc int)

func (*PfCtxS) GetStatus

func (ctx *PfCtxS) GetStatus() (code int)

func (*PfCtxS) GetTfunc

func (ctx *PfCtxS) GetTfunc() i18n.TranslateFunc

func (*PfCtxS) GetToken

func (ctx *PfCtxS) GetToken() (tok string)

func (*PfCtxS) GetTx

func (ctx *PfCtxS) GetTx() (tx *Tx)

func (*PfCtxS) GetUserAgent

func (ctx *PfCtxS) GetUserAgent() (string, string, string)

func (*PfCtxS) GroupHasCalendar

func (ctx *PfCtxS) GroupHasCalendar() bool

func (*PfCtxS) GroupHasFile

func (ctx *PfCtxS) GroupHasFile() bool

func (*PfCtxS) GroupHasWiki

func (ctx *PfCtxS) GroupHasWiki() bool

func (*PfCtxS) HasSelectedGroup

func (ctx *PfCtxS) HasSelectedGroup() bool

func (*PfCtxS) HasSelectedML

func (ctx *PfCtxS) HasSelectedML() bool

func (*PfCtxS) HasSelectedUser

func (ctx *PfCtxS) HasSelectedUser() bool

func (*PfCtxS) IAmGroupAdmin

func (ctx *PfCtxS) IAmGroupAdmin() bool

func (*PfCtxS) IAmGroupMember

func (ctx *PfCtxS) IAmGroupMember() bool

func (*PfCtxS) Init

func (ctx *PfCtxS) Init() (err error)

Constructor

func (*PfCtxS) IsBuffered

func (ctx *PfCtxS) IsBuffered() bool

func (*PfCtxS) IsGroupMember

func (ctx *PfCtxS) IsGroupMember() bool

func (*PfCtxS) IsLoggedIn

func (ctx *PfCtxS) IsLoggedIn() bool

func (*PfCtxS) IsPerm

func (ctx *PfCtxS) IsPerm(perms Perm, perm Perm) bool

func (*PfCtxS) IsPermSet

func (ctx *PfCtxS) IsPermSet(perms Perm, perm Perm) bool

func (*PfCtxS) IsSysAdmin

func (ctx *PfCtxS) IsSysAdmin() bool

func (*PfCtxS) Log

func (ctx *PfCtxS) Log(message string)

func (*PfCtxS) Logf

func (ctx *PfCtxS) Logf(format string, a ...interface{})

func (*PfCtxS) Login

func (ctx *PfCtxS) Login(username string, password string, twofactor string) (err error)

func (*PfCtxS) LoginToken

func (ctx *PfCtxS) LoginToken(tok string) (expsoon bool, err error)

func (*PfCtxS) Logout

func (ctx *PfCtxS) Logout()

func (*PfCtxS) Menu

func (ctx *PfCtxS) Menu(args []string, menu PfMenu) (err error)

func (*PfCtxS) MenuOverride

func (ctx *PfCtxS) MenuOverride(menu *PfMenu)

func (*PfCtxS) NewGroup

func (ctx *PfCtxS) NewGroup() PfGroup

func (*PfCtxS) NewGroupI

func (ctx *PfCtxS) NewGroupI() interface{}

func (*PfCtxS) NewToken

func (ctx *PfCtxS) NewToken() (err error)

func (*PfCtxS) NewUser

func (ctx *PfCtxS) NewUser() PfUser

func (*PfCtxS) NewUserI

func (ctx *PfCtxS) NewUserI() interface{}

func (*PfCtxS) Out

func (ctx *PfCtxS) Out(txt string)

func (*PfCtxS) OutBuffered

func (ctx *PfCtxS) OutBuffered(on bool)

func (*PfCtxS) OutLn

func (ctx *PfCtxS) OutLn(format string, a ...interface{})

func (*PfCtxS) Outf

func (ctx *PfCtxS) Outf(format string, a ...interface{})

func (*PfCtxS) PDbgf

func (ctx *PfCtxS) PDbgf(what string, perm Perm, format string, a ...interface{})

func (*PfCtxS) RestoreCreds

func (ctx *PfCtxS) RestoreCreds(creds PfCreds)

func (*PfCtxS) SelectEmail

func (ctx *PfCtxS) SelectEmail(email string) (err error)

func (*PfCtxS) SelectGroup

func (ctx *PfCtxS) SelectGroup(gr_name string, perms Perm) (err error)

func (*PfCtxS) SelectGroupA

func (ctx *PfCtxS) SelectGroupA(grp PfGroup, gr_name string, perms Perm) (err error)

Unless SysAdmin one cannot select a group one is not a member of

func (*PfCtxS) SelectML

func (ctx *PfCtxS) SelectML(ml_name string, perms Perm) (err error)

func (*PfCtxS) SelectMe

func (ctx *PfCtxS) SelectMe()

func (*PfCtxS) SelectObject

func (ctx *PfCtxS) SelectObject(obj *interface{})

func (*PfCtxS) SelectUser

func (ctx *PfCtxS) SelectUser(username string, perms Perm) (err error)

This creates a PfUser

func (*PfCtxS) SelectUser2FA

func (ctx *PfCtxS) SelectUser2FA(id int, perms Perm) (err error)

func (*PfCtxS) SelectedEmail

func (ctx *PfCtxS) SelectedEmail() (email PfUserEmail)

func (*PfCtxS) SelectedGroup

func (ctx *PfCtxS) SelectedGroup() (grp PfGroup)

func (*PfCtxS) SelectedML

func (ctx *PfCtxS) SelectedML() (ml PfML)

func (*PfCtxS) SelectedObject

func (ctx *PfCtxS) SelectedObject() (obj *interface{})

func (*PfCtxS) SelectedSelf

func (ctx *PfCtxS) SelectedSelf() bool

func (*PfCtxS) SelectedUser

func (ctx *PfCtxS) SelectedUser() (user PfUser)

func (*PfCtxS) SelectedUser2FA

func (ctx *PfCtxS) SelectedUser2FA() (tfa PfUser2FA)

func (*PfCtxS) SetAbort

func (ctx *PfCtxS) SetAbort(abort <-chan bool)

func (*PfCtxS) SetAppData

func (ctx *PfCtxS) SetAppData(appdata interface{})

func (*PfCtxS) SetClient

func (ctx *PfCtxS) SetClient(clientip net.IP, remote string, fullua string)

func (*PfCtxS) SetLanguage

func (ctx *PfCtxS) SetLanguage(name string)

func (*PfCtxS) SetModOpts

func (ctx *PfCtxS) SetModOpts(opts PfModOptsI)

func (*PfCtxS) SetOutUnbuffered

func (ctx *PfCtxS) SetOutUnbuffered(obj interface{}, fun string)

func (*PfCtxS) SetReturnCode

func (ctx *PfCtxS) SetReturnCode(rc int)

func (*PfCtxS) SetStatus

func (ctx *PfCtxS) SetStatus(code int)

func (*PfCtxS) SetTx

func (ctx *PfCtxS) SetTx(tx *Tx)

func (*PfCtxS) StoreCreds

func (ctx *PfCtxS) StoreCreds() (creds PfCreds)

func (*PfCtxS) SwapSysAdmin

func (ctx *PfCtxS) SwapSysAdmin() bool

func (*PfCtxS) TheUser

func (ctx *PfCtxS) TheUser() (user PfUser)

func (*PfCtxS) WalkMenu

func (ctx *PfCtxS) WalkMenu(args []string) (menu *PfMEntry, err error)

type PfDB

type PfDB struct {
	// contains filtered or unexported fields
}
var DB PfDB

Global database variable - there can only be one

func (*PfDB) AppUpgrade

func (db *PfDB) AppUpgrade() (err error)

func (*PfDB) Check

func (db *PfDB) Check() (msg string, err error)

Checks that our schema version is matching what we expect

func (*PfDB) Cleanup_psql

func (db *PfDB) Cleanup_psql() (err error)

func (*PfDB) Connect_def

func (db *PfDB) Connect_def() (err error)

func (*PfDB) Err

func (db *PfDB) Err(message string)

func (*PfDB) Errf

func (db *PfDB) Errf(format string, arg ...interface{})

func (*PfDB) Exec

func (db *PfDB) Exec(ctx PfCtx, audittxt string, affected int64, query string, args ...interface{}) (err error)

Exec() with forced requirement for audit message

func (*PfDB) ExecNA

func (db *PfDB) ExecNA(affected int64, query string, args ...interface{}) (err error)

func (*PfDB) Fix_Perms

func (db *PfDB) Fix_Perms() (err error)

func (*PfDB) GetAppSchemaVersion

func (db *PfDB) GetAppSchemaVersion() (version int, err error)

func (*PfDB) GetSchemaVersion

func (db *PfDB) GetSchemaVersion() (version int, err error)

func (*PfDB) Increase

func (db *PfDB) Increase(ctx PfCtx, audittxt, table string, ident string, what string) (err error)

func (*PfDB) Init

func (db *PfDB) Init(verbosity bool)

func (*PfDB) IsSelect

func (db *PfDB) IsSelect(query string) (ok bool)

func (*PfDB) QI

func (db *PfDB) QI(name string) string

func (*PfDB) Q_AddArg

func (db *PfDB) Q_AddArg(q *string, args *[]interface{}, arg interface{})

Simple query builder

func (*PfDB) Q_AddMultiClose

func (db *PfDB) Q_AddMultiClose(q *string)

func (*PfDB) Q_AddWhere

func (db *PfDB) Q_AddWhere(q *string, args *[]interface{}, str string, op string, arg interface{}, and bool, multi bool, argoffset int)

func (*PfDB) Q_AddWhereAnd

func (db *PfDB) Q_AddWhereAnd(q *string, args *[]interface{}, str string, arg interface{})

func (*PfDB) Q_AddWhereAndN

func (db *PfDB) Q_AddWhereAndN(q *string, args *[]interface{}, str string)

func (*PfDB) Q_AddWhereOpAnd

func (db *PfDB) Q_AddWhereOpAnd(q *string, args *[]interface{}, str string, op string, arg interface{})

func (*PfDB) Q_AddWhereOr

func (db *PfDB) Q_AddWhereOr(q *string, args *[]interface{}, str string, arg interface{})

func (*PfDB) Q_AddWhereOrN

func (db *PfDB) Q_AddWhereOrN(q *string, args *[]interface{}, str string)

func (*PfDB) Query

func (db *PfDB) Query(query string, args ...interface{}) (trows *Rows, err error)

Wrapper functions, ensuring database is connected

func (*PfDB) QueryFix

func (db *PfDB) QueryFix(q string) (f string)

func (*PfDB) QueryRow

func (db *PfDB) QueryRow(query string, args ...interface{}) (trow *Row)

Query for a Row, SELECT() only; thus no audittxt needed as nothing changes

func (*PfDB) QueryRowA

func (db *PfDB) QueryRowA(ctx PfCtx, audittxt string, query string, args ...interface{}) (trow *Row)

Query for a Row, with an Audittxt for situations where the query is an INSERT/UPDATE with RETURNING

func (*PfDB) QueryRowNA

func (db *PfDB) QueryRowNA(query string, args ...interface{}) (trow *Row)

Query for a Row, without Audittxt; use with care

func (*PfDB) SetAppVersion

func (db *PfDB) SetAppVersion(version int)

func (*PfDB) Setup_DB

func (db *PfDB) Setup_DB() (err error)

func (*PfDB) Setup_psql

func (db *PfDB) Setup_psql() (err error)

func (*PfDB) Silence

func (db *PfDB) Silence(braaf bool)

func (*PfDB) SizeReport

func (db *PfDB) SizeReport(num int) (sizes [][]string, err error)

func (*PfDB) TxBegin

func (db *PfDB) TxBegin(ctx PfCtx) (err error)

func (*PfDB) TxCommit

func (db *PfDB) TxCommit(ctx PfCtx) (err error)

func (*PfDB) TxRollback

func (db *PfDB) TxRollback(ctx PfCtx)

func (*PfDB) UpdateField

func (db *PfDB) UpdateField(ctx PfCtx, obj interface{}, ident string, table string, what string, val string) (updated bool, err error)

func (*PfDB) UpdateFieldMsg

func (db *PfDB) UpdateFieldMsg(ctx PfCtx, obj interface{}, ident string, table string, what string, val string) (err error)

func (*PfDB) UpdateFieldMulti

func (db *PfDB) UpdateFieldMulti(ctx PfCtx, obj interface{}, idents map[string]string, table string, what string, val string, checkperms bool) (updated bool, err error)

func (*PfDB) UpdateFieldMultiMsg

func (db *PfDB) UpdateFieldMultiMsg(ctx PfCtx, obj interface{}, set map[string]string, table string, what string, val string) (err error)

func (*PfDB) UpdateFieldNP

func (db *PfDB) UpdateFieldNP(ctx PfCtx, obj interface{}, ident string, table string, what string, val string) (updated bool, err error)

func (*PfDB) Upgrade

func (db *PfDB) Upgrade() (err error)

func (*PfDB) Verb

func (db *PfDB) Verb(message string)

func (*PfDB) Verbf

func (db *PfDB) Verbf(format string, arg ...interface{})

type PfDetail

type PfDetail struct {
	Type        string
	DisplayName string
}

func DetailList

func DetailList() (details []PfDetail, err error)

func (*PfDetail) ToString

func (td *PfDetail) ToString() (out string)

type PfDiff

type PfDiff struct {
	Common string
	Left   string
	Right  string
}

func DoDiff

func DoDiff(a string, b string) (diff []PfDiff)

func Wiki_Diff

func Wiki_Diff(ctx PfCtx, path string, revA string, revB string) (diff []PfDiff, err error)

type PfFile

type PfFile struct {
	File_id      int       `pfcol:"id" pftable:"file"`
	Path         string    `pfcol:"path" pftable:"file_namespace"`
	Filename     string    `pfcol:"filename" pftable:"file"`
	Revision     int       `pfcol:"revision"`
	Entered      time.Time `pfcol:"entered" pftable:"file_rev"`
	Description  string    `pfcol:"description"`
	SHA512       string    `pfcol:"sha512"`
	Size         int64     `pfcol:"size"`
	MimeType     string    `pfcol:"mimetype"`
	UserName     string    `pfcol:"member" pftable:"file_rev"`
	FullName     string    `pfcol:"descr" pftable:"member"`
	ChangeMsg    string    `pfcol:"changemsg"`
	FullPath     string    /* Not in the DB, see ApplyModOpts() */
	FullFileName string    /* Not in the DB, see ApplyModOpts() */
}

func File_ChildPagesList

func File_ChildPagesList(ctx PfCtx, path string, offset int, max int) (paths []PfFile, err error)

func File_RevisionList

func File_RevisionList(ctx PfCtx, path string, offset int, max int) (revs []PfFile, err error)

func (*PfFile) ApplyModOpts

func (file *PfFile) ApplyModOpts(ctx PfCtx)

Add some stuff we do not store in the DB but are useful

func (*PfFile) Fetch

func (file *PfFile) Fetch(ctx PfCtx, path string, rev string) (err error)

type PfFileOpts

type PfFileOpts struct {
	PfModOptsS
}

func File_GetModOpts

func File_GetModOpts(ctx PfCtx) PfFileOpts

type PfFileResult

type PfFileResult struct {
	Path    string
	Snippet string
}

type PfFunc

type PfFunc func(ctx PfCtx, args []string) (err error)

type PfGroup

type PfGroup interface {
	String() string
	GetGroupName() string
	GetGroupDesc() string
	HasWiki() bool
	HasFile() bool
	HasCalendar() bool

	Refresh() (err error)
	Exists(group_name string) (exists bool)
	Select(ctx PfCtx, group_name string, perms Perm) (err error)
	GetGroups(ctx PfCtx, username string) (groups []PfGroupMember, err error)
	GetGroupsAll() (groups []PfGroupMember, err error)
	GetKeys(ctx PfCtx, keyset map[[16]byte][]byte) (err error)
	IsMember(user string) (ismember bool, isadmin bool, out PfMemberState, err error)
	ListGroupMembersTot(search string) (total int, err error)
	ListGroupMembers(search string, username string, offset int, max int, nominated bool, inclhidden bool, exact bool) (members []PfGroupMember, err error)
	Add_default_mailinglists(ctx PfCtx) (err error)
	Member_add(ctx PfCtx) (err error)
	Member_remove(ctx PfCtx) (err error)
	Member_set_state(ctx PfCtx, state string) (err error)
	Member_set_admin(ctx PfCtx, isadmin bool) (err error)
	GetVcards() (vcard string, err error)
	// contains filtered or unexported methods
}

func NewPfGroup

func NewPfGroup() PfGroup

Should not be directly called, use ctx or cui.NewGroup() instead

type PfGroupMember

type PfGroupMember interface {
	SQL_Selects() string
	SQL_Froms() string
	SQL_Scan(rows *Rows) (err error)
	Set(groupname, groupdesc, username, fullname, affiliation string, groupadmin bool, groupstate string, cansee bool, email, pgpkey_id, entered, activity, telephone, sms, airport string)
	GetGroupName() string
	GetGroupDesc() string
	GetUserName() string
	GetFullName() string
	GetEmail() string
	GetAffiliation() string
	GetGroupAdmin() bool
	GetGroupState() string
	GetGroupCanSee() bool
	GetPGPKeyID() string
	HasPGP() bool
	GetEntered() string
	GetActivity() string
	GetTel() string
	GetSMS() string
	GetAirport() string
}

func NewPfGroupMember

func NewPfGroupMember() PfGroupMember

type PfGroupMemberS

type PfGroupMemberS struct {
	UserName    string
	FullName    string
	Email       string
	Affiliation string
	GroupAdmin  bool
	GroupState  string
	GroupCanSee bool
	GroupName   string
	GroupDesc   string
	PGPKeyID    string
	Entered     string
	Activity    string
	Tel         string
	SMS         string
	Airport     string
}

func (*PfGroupMemberS) GetActivity

func (grpm *PfGroupMemberS) GetActivity() string

func (*PfGroupMemberS) GetAffiliation

func (grpm *PfGroupMemberS) GetAffiliation() string

func (*PfGroupMemberS) GetAirport

func (grpm *PfGroupMemberS) GetAirport() string

func (*PfGroupMemberS) GetEmail

func (grpm *PfGroupMemberS) GetEmail() string

func (*PfGroupMemberS) GetEntered

func (grpm *PfGroupMemberS) GetEntered() string

func (*PfGroupMemberS) GetFullName

func (grpm *PfGroupMemberS) GetFullName() string

func (*PfGroupMemberS) GetGroupAdmin

func (grpm *PfGroupMemberS) GetGroupAdmin() bool

func (*PfGroupMemberS) GetGroupCanSee

func (grpm *PfGroupMemberS) GetGroupCanSee() bool

func (*PfGroupMemberS) GetGroupDesc

func (grpm *PfGroupMemberS) GetGroupDesc() string

func (*PfGroupMemberS) GetGroupName

func (grpm *PfGroupMemberS) GetGroupName() string

func (*PfGroupMemberS) GetGroupState

func (grpm *PfGroupMemberS) GetGroupState() string

func (*PfGroupMemberS) GetPGPKeyID

func (grpm *PfGroupMemberS) GetPGPKeyID() string

func (*PfGroupMemberS) GetSMS

func (grpm *PfGroupMemberS) GetSMS() string

func (*PfGroupMemberS) GetTel

func (grpm *PfGroupMemberS) GetTel() string

func (*PfGroupMemberS) GetUserName

func (grpm *PfGroupMemberS) GetUserName() string

func (*PfGroupMemberS) HasPGP

func (grpm *PfGroupMemberS) HasPGP() bool

func (*PfGroupMemberS) SQL_Froms

func (grpm *PfGroupMemberS) SQL_Froms() string

func (*PfGroupMemberS) SQL_Scan

func (grpm *PfGroupMemberS) SQL_Scan(rows *Rows) (err error)

func (*PfGroupMemberS) SQL_Selects

func (grpm *PfGroupMemberS) SQL_Selects() (q string)

func (*PfGroupMemberS) Set

func (grpm *PfGroupMemberS) Set(groupname, groupdesc, username, fullname, affiliation string, groupadmin bool, groupstate string, cansee bool, email, pgpkey_id, entered, activity, telephone, sms, airport string)

type PfGroupS

type PfGroupS struct {
	GroupName    string `label:"Group Name" pfset:"nobody" pfget:"group_member" pfcol:"ident"`
	GroupDesc    string `label:"Description" pfcol:"descr" pfset:"group_admin"`
	PGP_Required bool   `label:"PGP Required" pfset:"group_admin"`
	Has_Wiki     bool   `label:"Wiki Module" pfset:"group_admin"`
	Has_File     bool   `label:"Files Module" pfset:"group_admin"`
	Has_Calendar bool   `label:"Calendar Module" pfset:"group_admin"`
	Button       string `label:"Update Group" pftype:"submit"`
}

func (*PfGroupS) Add_default_mailinglists

func (grp *PfGroupS) Add_default_mailinglists(ctx PfCtx) (err error)

func (*PfGroupS) Exists

func (grp *PfGroupS) Exists(group_name string) (exists bool)

func (*PfGroupS) GetGroupDesc

func (grp *PfGroupS) GetGroupDesc() string

func (*PfGroupS) GetGroupName

func (grp *PfGroupS) GetGroupName() string

func (*PfGroupS) GetGroups

func (grp *PfGroupS) GetGroups(ctx PfCtx, username string) (members []PfGroupMember, err error)

* Return the set of groups that the username is connected to * If active is set nominations will also appear

func (*PfGroupS) GetGroupsAll

func (grp *PfGroupS) GetGroupsAll() (members []PfGroupMember, err error)

func (*PfGroupS) GetKeys

func (grp *PfGroupS) GetKeys(ctx PfCtx, keyset map[[16]byte][]byte) (err error)

func (*PfGroupS) GetVcards

func (grp *PfGroupS) GetVcards() (vcard string, err error)

func (*PfGroupS) HasCalendar

func (grp *PfGroupS) HasCalendar() bool

func (*PfGroupS) HasFile

func (grp *PfGroupS) HasFile() bool

func (*PfGroupS) HasWiki

func (grp *PfGroupS) HasWiki() bool

func (*PfGroupS) IsMember

func (grp *PfGroupS) IsMember(user string) (ismember bool, isadmin bool, out PfMemberState, err error)

func (*PfGroupS) ListGroupMembers

func (grp *PfGroupS) ListGroupMembers(search string, username string, offset int, max int, nominated bool, inclhidden bool, exact bool) (members []PfGroupMember, err error)

Note: This implementation does not use the 'username' variable, but other implementations might

func (*PfGroupS) ListGroupMembersTot

func (grp *PfGroupS) ListGroupMembersTot(search string) (total int, err error)

func (*PfGroupS) Member_add

func (grp *PfGroupS) Member_add(ctx PfCtx) (err error)

func (*PfGroupS) Member_remove

func (grp *PfGroupS) Member_remove(ctx PfCtx) (err error)

func (*PfGroupS) Member_set_admin

func (grp *PfGroupS) Member_set_admin(ctx PfCtx, isadmin bool) (err error)

func (*PfGroupS) Member_set_state

func (grp *PfGroupS) Member_set_state(ctx PfCtx, state string) (err error)

func (*PfGroupS) Refresh

func (grp *PfGroupS) Refresh() (err error)

func (*PfGroupS) Select

func (grp *PfGroupS) Select(ctx PfCtx, group_name string, perms Perm) (err error)

func (*PfGroupS) String

func (grp *PfGroupS) String() string

type PfLanguage

type PfLanguage struct {
	Name string
	Code string
}

func LanguageList

func LanguageList() (languages []PfLanguage, err error)

func (*PfLanguage) ToString

func (tl *PfLanguage) ToString() (out string)

type PfMEntry

type PfMEntry struct {
	Cmd      string
	Fun      PfFunc
	Args_min int
	Args_max int
	Args     []string
	Perms    Perm
	Desc     string
}

func NewPfMEntry

func NewPfMEntry(Cmd string, Fun PfFunc, Args_min int, Args_max int, Args []string, Perms Perm, Desc string) PfMEntry

type PfML

type PfML struct {
	ListName     string `label:"List Name" pfset:"nobody" pfget:"user" pfcol:"lhs" hint:"Name of this Mailing List"`
	GroupName    string `label:"Group Name" pfset:"nobody" pfget:"user" pfcol:"trustgroup" hint:"Group this list belongs to"`
	Descr        string `label:"Description" pfset:"group_admin" hint:"Description of this list"`
	Members_only bool   `label:"Members Only" pfset:"group_admin" hint:"Only list members can post to this list"`
	Can_add_self bool   `label:"Can Add Self" pfset:"group_admin" hint:"Can members of the group subscribe themselves to the list?"`
	Automatic    bool   `label:"Automatic" pfset:"group_admin" hint:"If new group members are automatically added to the list"`
	Always_crypt bool   `label:"Always Encrypt" pfset:"group_admin" hint:"Always require messages to be PGP encrypted"`
	Pubkey       string `label:"Public PGP Key" pfset:"nobody" pfget:"user" pfcol:"pubkey"`
	Seckey       string `label:"Secret PGP Key" pfset:"nobody" pfget:"nobody" pfcol:"seckey" pfskipfailperm:"yes"`
	Address      string /* Not retrieved with Fetch() */
	Button       string `label:"Update Configuration" pftype:"submit"`
	Members      int    /* Not retrieved with Fetch() */
	Subscribed   bool   /* Not retrieved with Fetch() */
}

func NewPfML

func NewPfML() *PfML

func (*PfML) GetKey

func (ml *PfML) GetKey(ctx PfCtx, keyset map[[16]byte][]byte) (err error)

func (*PfML) IsMember

func (ml *PfML) IsMember(user PfUser) (ok bool, err error)

func (*PfML) List

func (ml *PfML) List(ctx PfCtx, grp PfGroup) (mls []PfML, err error)

func (*PfML) ListGroupMembers

func (ml *PfML) ListGroupMembers(search string, offset int, max int) (members []PfMLUser, err error)

func (*PfML) ListGroupMembersMax

func (ml *PfML) ListGroupMembersMax(search string) (total int, err error)

func (*PfML) ListWithUser

func (ml *PfML) ListWithUser(ctx PfCtx, grp PfGroup, user PfUser) (mls []PfML, err error)

func (*PfML) Refresh

func (ml *PfML) Refresh() (err error)

func (*PfML) Select

func (ml *PfML) Select(ctx PfCtx, grp PfGroup, ml_name string, perms Perm) (err error)

type PfMLUser

type PfMLUser struct {
	UserName      string
	Uuid          string
	FullName      string
	Affiliation   string
	IsSysAdmin    bool
	LoginAttempts int
}

func (*PfMLUser) GetAffiliation

func (mlu *PfMLUser) GetAffiliation() string

func (*PfMLUser) GetFullName

func (mlu *PfMLUser) GetFullName() string

func (*PfMLUser) GetUserName

func (mlu *PfMLUser) GetUserName() string

type PfMemberState

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

type PfMenu

type PfMenu struct {
	M []PfMEntry
}

func NewPfMenu

func NewPfMenu(m []PfMEntry) PfMenu

func StructMenu

func StructMenu(ctx PfCtx, subjects []string, obj interface{}, onlyslices bool, fun PfFunc) (menu PfMenu, err error)

Create a "get" or "set" menu from a struct

func StructMenuA

func StructMenuA(ctx PfCtx, subjects []string, objtrail []interface{}, obj interface{}, onlyslices bool, fun PfFunc, isedit bool, nargs int) (menu PfMenu, err error)

func (*PfMenu) Add

func (menu *PfMenu) Add(m ...PfMEntry)

func (*PfMenu) AddPerms

func (menu *PfMenu) AddPerms(cmd string, perms Perm)

Or new permissions into it, useful to mark a menu item hidden

func (*PfMenu) DelPerms

func (menu *PfMenu) DelPerms(cmd string, perms Perm)

func (*PfMenu) Remove

func (menu *PfMenu) Remove(cmd string)

func (*PfMenu) Replace

func (menu *PfMenu) Replace(cmd string, fun PfFunc)

func (*PfMenu) SetPerms

func (menu *PfMenu) SetPerms(cmd string, perms Perm)

type PfMenuI

type PfMenuI func(ctx PfCtx, menu *PfMenu)

type PfMessage

type PfMessage struct {
	Id        int           `pfcol:"id"`
	Path      string        `pfcol:"path"`
	Depth     int           `pfcol:"depth"`
	Title     string        `pfcol:"title"`
	Plaintext string        `pfcol:"plaintext"`
	HTML      template.HTML `pfcol:"html"`
	Entered   time.Time     `pfcol:"entered"`
	UserName  string        `pfcol:"member"`
	FullName  string        `pfcol:"descr" pftable:"member"`
	Seen      pq.NullTime   `pfcol:"entered" pftable:"msg_read"`
}

func Msg_Get

func Msg_Get(ctx PfCtx, path string) (msg PfMessage, err error)

func Msg_GetThread

func Msg_GetThread(ctx PfCtx, path string, mindepth int, maxdepth int, offset int, max int) (msgs []PfMessage, err error)

type PfModOptsI

type PfModOptsI interface {
	IsModOpts() bool
}

type PfModOptsS

type PfModOptsS struct {
	/* CLI command prefix, eg 'group wiki' */
	Cmdpfx string

	/* URL prefix, typically System_Get().PublicURL() */
	URLpfx string

	/* Path Root */
	Pathroot string

	/* URL root, inside the hostname, eg '/group/name/wiki/' */
	URLroot string
}

func PfModOpts

func PfModOpts(ctx PfCtx, cmdpfx string, path_root string, web_root string) PfModOptsS

func (PfModOptsS) IsModOpts

func (m PfModOptsS) IsModOpts() bool

type PfMsgOpts

type PfMsgOpts struct {
	PfModOptsS

	/*
	 * How deep messages are still considered Subjects
	 * Thread_depth + 1 == messages
	 */
	Thread_depth int

	/* Subforum title */
	Title string
}

func Msg_GetModOpts

func Msg_GetModOpts(ctx PfCtx) PfMsgOpts

type PfNewCtx

type PfNewCtx func() PfCtx

type PfNewGroupI

type PfNewGroupI func() (user PfGroup)

type PfNewUserI

type PfNewUserI func() (user PfUser)

type PfPWRules

type PfPWRules struct {
	Min_length   int
	Max_length   int
	Min_letters  int
	Min_uppers   int
	Min_lowers   int
	Min_numbers  int
	Min_specials int
}

type PfPass

type PfPass struct {
}

func (*PfPass) GenPass

func (pw *PfPass) GenPass(length int) (pass string, err error)

func (*PfPass) GenRand

func (pw *PfPass) GenRand(length int) (bytes []byte, err error)

func (*PfPass) GenRandHex

func (pw *PfPass) GenRandHex(length int) (hex string, err error)

func (*PfPass) Make

func (pw *PfPass) Make(password string) (hash string, err error)

* For the time being, all passwords are SHA512 hashed

func (*PfPass) SOTPHash

func (pw *PfPass) SOTPHash(secret string) (out string)

func (*PfPass) Verify

func (pw *PfPass) Verify(password string, hashedPassword string) (err error)

* hashedPassword is in the semi-standardized /etc/shadow passwd format * the format can be: * $<hashtype>$<salt>$<hash> * $<hashtype>$rounds=<iter>$<salt>$<hash>

func (*PfPass) VerifyHOTP

func (pw *PfPass) VerifyHOTP(key string, counter int64, twofactor string) bool

func (*PfPass) VerifyPWRules

func (pw *PfPass) VerifyPWRules(password string, r PfPWRules) (probs []string)

func (*PfPass) VerifySOTP

func (pw *PfPass) VerifySOTP(key string, twofactor string) bool

func (*PfPass) VerifyTOTP

func (pw *PfPass) VerifyTOTP(key string, twofactor string) bool

type PfPostBecomeI

type PfPostBecomeI func(ctx PfCtx)

type PfPostCreateI

type PfPostCreateI func(ctx PfCtx, user PfUser) (err error)

type PfPostFetchI

type PfPostFetchI func(ctx PfCtx, user PfUser, username string, in_err error) (err error)

type PfQuery

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

type PfRenderer

type PfRenderer struct {
	*blackfriday.Html
}

Wrap blackfriday

func (*PfRenderer) BlockCode

func (rnd *PfRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string)

Override blockcode

type PfSearchResult

type PfSearchResult struct {
	Source  string `json:"source"`
	Title   string `json:"title"`
	Link    string `json:"link"`
	Summary string `json:"summary"`
}
func Search(ctx PfCtx, async bool, search string) (results []PfSearchResult, te time.Duration, err error)

type PfSearcherI

type PfSearcherI func(ctx PfCtx, c chan PfSearchResult, search string, abort <-chan bool) (err error)

type PfSys

type PfSys struct {
	Name             string `label:"System Name" pfset:"sysadmin" hint:"Name of the System"`
	Welcome          string `label:"Welcome Text" pftype:"text" pfset:"sysadmin" pfcol:"welcome_text" hint:"Welcome message shown on login page"`
	AdminName        string `label:"Name of the Administrator(s)" pfset:"sysadmin" hint:"Name of the Administrator, shown at bottom of the page"`
	AdminEmail       string `` /* 128-byte string literal not displayed */
	AdminEmailPublic bool   `` /* 139-byte string literal not displayed */
	CopyYears        string `label:"Copyright Years" pfset:"sysadmin" hint:"Years that copyright ownership is claimed"`
	EmailDomain      string `label:"Email Domain" pfset:"sysadmin" pfcol:"email_domain" hint:"The domain where emails are sourced from"`
	PublicURL        string `` /* 178-byte string literal not displayed */
	PeopleDomain     string `` /* 154-byte string literal not displayed */
	CLIEnabled       bool   `` /* 169-byte string literal not displayed */
	APIEnabled       bool   `` /* 187-byte string literal not displayed */
	OAuthEnabled     bool   `` /* 166-byte string literal not displayed */
	NoIndex          bool   `` /* 140-byte string literal not displayed */
	EmailSig         string `label:"Email Signature" pftype:"text" pfset:"sysadmin" pfcol:"email_sig" hint:"Signature appended to mailinglist messages"`
	Require2FA       bool   `` /* 161-byte string literal not displayed */
	PW_comment       string `` /* 132-byte string literal not displayed */
	PW_Enforce       bool   `pfsection:"Password Rules" label:"Enforce Rules" hint:"When enabled the rules below are enforced on new passwords"`
	PW_Length        int    `pfsection:"Password Rules" label:"Minimal Password Length (suggested: 12, min: 8)" min:"8"`
	PW_LengthMax     int    `pfsection:"Password Rules" label:"Maximal Password Length (suggested: 1024)"`
	PW_Letters       int    `pfsection:"Password Rules" label:"Minimum amount of Letters"`
	PW_Uppers        int    `pfsection:"Password Rules" label:"Minimum amount of Uppercase characters"`
	PW_Lowers        int    `pfsection:"Password Rules" label:"Minimum amount of Lowercase characters"`
	PW_Numbers       int    `pfsection:"Password Rules" label:"Minimum amount of Numbers"`
	PW_Specials      int    `pfsection:"Password Rules" label:"Minimum amount of Special characters"`
	SARestrict       string `` /* 362-byte string literal not displayed */
	HeaderImg        string `label:"Header Image" pfset:"sysadmin" pfcol:"header_image" hint:"Image shown on the Welcome page"`
	LogoImg          string `label:"Logo Image" pfset:"sysadmin" pfcol:"logo_image" hint:"Logo shown in the menu bar"`
	UnknownImg       string `label:"Unknown Person Image" pfset:"sysadmin" pfcol:"unknown_image" hint:"Logo shown for users who do not have an image set"`
	ShowVersion      bool   `` /* 173-byte string literal not displayed */
	Button           string `label:"Update Settings" pftype:"submit"`
	// contains filtered or unexported fields
}

func System_Get

func System_Get() (system *PfSys)

func (*PfSys) PWRules

func (system *PfSys) PWRules() (rules PfPWRules)

Create a PfPWRules object

func (*PfSys) Refresh

func (system *PfSys) Refresh() (err error)

type PfUser

type PfUser interface {
	SetUserName(name string)
	GetUserName() string
	SetFullName(name string)
	GetFullName() string
	SetFirstName(name string)
	GetFirstName() string
	SetLastName(name string)
	GetLastName() string
	SetSysAdmin(isone bool)
	CanBeSysAdmin() bool
	IsSysAdmin() bool
	GetLoginAttempts() int
	GetUuid() string
	GetAffiliation() string
	GetGroups(ctx PfCtx) (groups []PfGroupMember, err error)
	IsMember(ctx PfCtx, groupname string) (ismember bool)
	GetListMax(search string) (total int, err error)
	GetList(ctx PfCtx, search string, offset int, max int, exact bool) (users []PfUser, err error)

	Refresh(ctx PfCtx) (err error)
	Select(ctx PfCtx, username string, perms Perm) (err error)
	SetRecoverToken(ctx PfCtx, token string) (err error)
	SharedGroups(ctx PfCtx, otheruser PfUser) (ok bool, err error)
	GetImage(ctx PfCtx) (img []byte, err error)
	GetHideEmail() (hide_email bool)
	GetKeys(ctx PfCtx, keyset map[[16]byte][]byte) (err error)
	GetDetails() (details []PfUserDetail, err error)
	GetLanguages() (languages []PfUserLanguage, err error)
	Get(what string) (val string, err error)
	GetTime(what string) (val time.Time, err error)
	SetPassword(ctx PfCtx, pwtype string, password string) (err error)
	CheckAuth(ctx PfCtx, username string, password string, twofactor string) (err error)
	Verify_Password(ctx PfCtx, password string) (err error)
	GetSF() (sf string, err error)
	GetPriEmail(ctx PfCtx, recovery bool) (tue PfUserEmail, err error)
	GetPriEmailString(ctx PfCtx, recovery bool) (email string)
	Fetch2FA() (tokens []PfUser2FA, err error)
	Verify_TwoFactor(ctx PfCtx, twofactor string, id int) (err error)
	GetLastActivity(ctx PfCtx) (entered time.Time, ip string)

	Create(ctx PfCtx, username string, email string, bio_info string, affiliation string, descr string) (err error)
	PostCreate(ctx PfCtx) (err error)
	PostFetch(ctx PfCtx, username string, in_err error) (err error)
	// contains filtered or unexported methods
}

func NewPfUser

func NewPfUser(postcreate PfPostCreateI, postfetch PfPostFetchI) PfUser

Should not be directly called, use ctx or cui.NewUser() instead

func NewPfUserA

func NewPfUserA() PfUser

type PfUser2FA

type PfUser2FA struct {
	Id       int       `label:"ID" pfset:"none" pfcol:"id"`
	UserName string    `label:"UserName" pfset:"self" pfcol:"member" pftype:"ident" hint:"Owner of the Token"`
	Name     string    `label:"Description" pfset:"self" pfcol:"descr" hint:"Helpful name of the token"`
	Type     string    `label:"Type" pfset:"self" pfcol:"type"`
	Entered  time.Time `label:"Entered" pfset:"nobody" pfget:"user"`
	Active   bool      `label:"Active" pfset:"self" pfcol:"active" hint:"Is the token active"`
	Key      string    `label:"Key" pfset:"self" pfcol:"key"`
	Counter  int       `trilanel:"Count" pfset:"self" pfcol:"counter" hint:"HOTP counter"`
}

func NewPfUser2FA

func NewPfUser2FA() *PfUser2FA

func (*PfUser2FA) Refresh

func (tfa *PfUser2FA) Refresh() (err error)

func (*PfUser2FA) Select

func (tfa *PfUser2FA) Select(ctx PfCtx, id int, perms Perm) (err error)

func (*PfUser2FA) String

func (tfa *PfUser2FA) String() (out string)

type PfUserDetail

type PfUserDetail struct {
	Detail  PfDetail
	Value   string
	Entered time.Time
}

type PfUserEmail

type PfUserEmail struct {
	Member        string          `label:"Member" pfset:"self" pfcol:"member" pftype:"ident" hint:"Owner of the Verification Code"`
	FullName      string          `label:"Full Name" pfset:"none" pftable:"member" pfcol:"descr"`
	Email         string          `label:"Email" pftype:"email" pfset:"none" pfcol:"email"`
	PgpKeyID      string          `label:"PGP Key ID" pfset:"none" pfcol:"pgpkey_id"`
	PgpKeyExpire  time.Time       `label:"PGP Key Expire" pfset:"nobody" pfget:"user" pfcol:"pgpkey_expire"`
	Keyring       string          `label:"Keyring" pftype:"file" pfset:"self" pfcol:"keyring"`
	KeyringUpdate time.Time       `label:"Keyring Updated At" pfset:"nobody" pfget:"user" pfcol:"keyring_update_at"`
	VerifyCode    string          `label:"Verification Code" pfset:"nobody" pfget:"user" pfcol:"verify_token"`
	Verified      bool            `label:"Verified" pfset:"nobody" pfget:"user" pfcol:"verified"`
	Groups        []PfGroupMember /* Used by List() */
}

func NewPfUserEmail

func NewPfUserEmail() *PfUserEmail

func (*PfUserEmail) Fetch

func (uem *PfUserEmail) Fetch(email string) (err error)

func (*PfUserEmail) FetchGroups

func (uem *PfUserEmail) FetchGroups(ctx PfCtx) (err error)

func (*PfUserEmail) List

func (uem *PfUserEmail) List(ctx PfCtx, user PfUser) (emails []PfUserEmail, err error)

type PfUserLanguage

type PfUserLanguage struct {
	Language PfLanguage
	Skill    string
	Entered  time.Time
}

type PfUserS

type PfUserS struct {
	Uuid          string    `label:"UUID" coalesce:"00000000-0000-0000-0000-000000000000" pfset:"nobody" pfget:"sysadmin" pfskipfailperm:"yes"`
	Image         string    `` /* 156-byte string literal not displayed */
	UserName      string    `label:"User Name" pfset:"self" pfget:"user_view" pfcol:"ident" min:"3" hint:"The username of this user" pfformedit:"no"`
	FullName      string    `label:"Full Name" pfset:"self" pfget:"user_view" pfcol:"descr" hint:"Full Name of this user"`
	FirstName     string    `label:"First Name" pfset:"self" pfget:"user_view" pfcol:"name_first" hint:"The First Name of the user"`
	LastName      string    `label:"Last Name" pfset:"self" pfget:"user_view" pfcol:"name_last" hint:"The Last name of the user"`
	Affiliation   string    `label:"Affiliation" pfset:"self" pfget:"user_view" hint:"Who the user is affiliated to"`
	Postal        string    `` /* 129-byte string literal not displayed */
	Sms           string    `` /* 128-byte string literal not displayed */
	Im            string    `label:"I.M." pfset:"self" pfget:"user_view" pfcol:"im_info" hint:"Instant Messaging details"`
	Timezone      string    `label:"Timezone" pfset:"self" pfget:"user_view" pfcol:"tz_info" hint:"Timezone details"`
	Telephone     string    `` /* 149-byte string literal not displayed */
	Airport       string    `label:"Airport" min:"3" max:"3" pfset:"self" pfget:"user_view" hint:"Closest airport for this user"`
	Biography     string    `label:"Biography" pftype:"text" pfset:"self" pfget:"user_view" pfcol:"bio_info" hint:"Biography for this user"`
	IsSysadmin    bool      `` /* 152-byte string literal not displayed */
	CanBeSysadmin bool      `` /* 171-byte string literal not displayed */
	LoginAttempts int       `` /* 187-byte string literal not displayed */
	No_email      bool      `` /* 137-byte string literal not displayed */
	Hide_email    bool      `` /* 156-byte string literal not displayed */
	RecoverEmail  string    `` /* 154-byte string literal not displayed */
	Furlough      bool      `label:"Furlough" pfset:"self" pfget:"user,user_view" hint:"Extended holiday or furlough"`
	Entered       time.Time `label:"Entered" pfset:"nobody" pfget:"user,user_view" hint:"Timestamp in UTC"`
	Activity      time.Time `label:"Last Activity" pfset:"nobody" pfget:"user,user_view" hint:"Timestamp in UTC"`
	Button        string    `label:"Update Profile" pftype:"submit"`
	Password      string    `pfset:"nobody" pfget:"nobody" pfskipfailperm:"yes"`
	Passwd_chat   string    `pfset:"nobody" pfget:"nobody" pfskipfailperm:"yes"`
	// contains filtered or unexported fields
}

* All values have to be exportable, otherwise our StructFetch() etc tricks do not work * * But that is also the extent that these should be used, they should always be accessed * using the interface, not directly (direct access only internally). * * Even templates need to use Get*() variants as they receive interfaces.

func (*PfUserS) CanBeSysAdmin

func (user *PfUserS) CanBeSysAdmin() bool

func (*PfUserS) CheckAuth

func (user *PfUserS) CheckAuth(ctx PfCtx, username string, password string, twofactor string) (err error)

func (*PfUserS) Create

func (user *PfUserS) Create(ctx PfCtx, username string, email string, bio_info string, affiliation string, descr string) (err error)

func (*PfUserS) Fetch2FA

func (user *PfUserS) Fetch2FA() (tokens []PfUser2FA, err error)

Extends PfUserS object

func (*PfUserS) Get

func (user *PfUserS) Get(what string) (val string, err error)

PfUser Internal

func (*PfUserS) GetAffiliation

func (user *PfUserS) GetAffiliation() string

func (*PfUserS) GetDetails

func (user *PfUserS) GetDetails() (details []PfUserDetail, err error)

func (*PfUserS) GetFirstName

func (user *PfUserS) GetFirstName() string

func (*PfUserS) GetFullName

func (user *PfUserS) GetFullName() string

func (*PfUserS) GetGroups

func (user *PfUserS) GetGroups(ctx PfCtx) (groups []PfGroupMember, err error)

func (*PfUserS) GetHideEmail

func (user *PfUserS) GetHideEmail() (hide_email bool)

func (*PfUserS) GetImage

func (user *PfUserS) GetImage(ctx PfCtx) (img []byte, err error)

func (*PfUserS) GetKeys

func (user *PfUserS) GetKeys(ctx PfCtx, keyset map[[16]byte][]byte) (err error)

func (*PfUserS) GetLanguages

func (user *PfUserS) GetLanguages() (output []PfUserLanguage, err error)

func (*PfUserS) GetLastActivity

func (user *PfUserS) GetLastActivity(ctx PfCtx) (entered time.Time, ip string)

func (*PfUserS) GetLastName

func (user *PfUserS) GetLastName() string

func (*PfUserS) GetList

func (user *PfUserS) GetList(ctx PfCtx, search string, offset int, max int, exact bool) (users []PfUser, err error)

TODO: Verify: Only show member of groups my user is associated with and are non-anonymous

func (*PfUserS) GetListMax

func (user *PfUserS) GetListMax(search string) (total int, err error)

func (*PfUserS) GetLoginAttempts

func (user *PfUserS) GetLoginAttempts() int

func (*PfUserS) GetPriEmail

func (user *PfUserS) GetPriEmail(ctx PfCtx, recovery bool) (tue PfUserEmail, err error)

Extends PfUserS

func (*PfUserS) GetPriEmailString

func (user *PfUserS) GetPriEmailString(ctx PfCtx, recovery bool) (email string)

func (*PfUserS) GetSF

func (user *PfUserS) GetSF() (sf string, err error)

func (*PfUserS) GetTime

func (user *PfUserS) GetTime(what string) (val time.Time, err error)

func (*PfUserS) GetUserName

func (user *PfUserS) GetUserName() string

func (*PfUserS) GetUuid

func (user *PfUserS) GetUuid() string

func (*PfUserS) IsMember

func (user *PfUserS) IsMember(ctx PfCtx, groupname string) (ismember bool)

func (*PfUserS) IsSysAdmin

func (user *PfUserS) IsSysAdmin() bool

func (*PfUserS) PostCreate

func (user *PfUserS) PostCreate(ctx PfCtx) (err error)

func (*PfUserS) PostFetch

func (user *PfUserS) PostFetch(ctx PfCtx, username string, in_err error) (err error)

func (*PfUserS) Refresh

func (user *PfUserS) Refresh(ctx PfCtx) (err error)

func (*PfUserS) Select

func (user *PfUserS) Select(ctx PfCtx, username string, perms Perm) (err error)

func (*PfUserS) SetFirstName

func (user *PfUserS) SetFirstName(name string)

func (*PfUserS) SetFullName

func (user *PfUserS) SetFullName(name string)

func (*PfUserS) SetLastName

func (user *PfUserS) SetLastName(name string)

func (*PfUserS) SetPassword

func (user *PfUserS) SetPassword(ctx PfCtx, pwtype string, password string) (err error)

func (*PfUserS) SetRecoverToken

func (user *PfUserS) SetRecoverToken(ctx PfCtx, token string) (err error)

func (*PfUserS) SetSysAdmin

func (user *PfUserS) SetSysAdmin(isone bool)

func (*PfUserS) SetUserName

func (user *PfUserS) SetUserName(name string)

func (*PfUserS) SharedGroups

func (user *PfUserS) SharedGroups(ctx PfCtx, otheruser PfUser) (ok bool, err error)

func (*PfUserS) Verify_Password

func (user *PfUserS) Verify_Password(ctx PfCtx, password string) (err error)

* This only verifies the "portal" password * * Chat & jabber passwords are directly checked by ircd & ejabberd

func (*PfUserS) Verify_TwoFactor

func (user *PfUserS) Verify_TwoFactor(ctx PfCtx, twofactor string, id int) (err error)

* If id is set to a value other than zero this function will * compare with that one and only one token, even if it disabled.

type PfWikiHTML

type PfWikiHTML struct {
	HTML_TOC  template.HTML `pfcol:"html_toc"`
	HTML_Body template.HTML `pfcol:"html_body"`
	Entered   time.Time     `pftable:"wiki_page_rev"`
	UserName  string        `pfcol:"member"`
	FullName  string        `pfcol:"descr" pftable:"member"`
}

func (*PfWikiHTML) Fetch

func (wiki *PfWikiHTML) Fetch(ctx PfCtx, path string, rev string) (err error)

type PfWikiMarkdown

type PfWikiMarkdown struct {
	Markdown string `pfcol:"markdown"`
}

func (*PfWikiMarkdown) Fetch

func (wiki *PfWikiMarkdown) Fetch(ctx PfCtx, path string, rev string) (err error)

type PfWikiOpts

type PfWikiOpts struct {
	PfModOptsS
}

func Wiki_GetModOpts

func Wiki_GetModOpts(ctx PfCtx) PfWikiOpts

type PfWikiPage

type PfWikiPage struct {
	Path     string
	Entered  time.Time
	Title    string
	FullPath string /* Not in the DB, see ApplyModOpts() */
}

func Wiki_ChildPagesList

func Wiki_ChildPagesList(ctx PfCtx, path string, offset int, max int) (paths []PfWikiPage, err error)

func (*PfWikiPage) ApplyModOpts

func (wiki *PfWikiPage) ApplyModOpts(ctx PfCtx)

type PfWikiResult

type PfWikiResult struct {
	Path    string
	Title   string
	Snippet string
}

func Wiki_SearchList

func Wiki_SearchList(ctx PfCtx, search string, offset int, max int) (results []PfWikiResult, err error)

type PfWikiRev

type PfWikiRev struct {
	Revision  int
	RevisionB int
	Entered   time.Time
	UserName  string
	FullName  string
	ChangeMsg string
}

func Wiki_RevisionList

func Wiki_RevisionList(ctx PfCtx, path string, offset int, max int) (revs []PfWikiRev, err error)

type Row

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

func (*Row) Scan

func (row *Row) Scan(args ...interface{}) (err error)

type Rows

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

func (*Rows) Close

func (rows *Rows) Close()

func (*Rows) Next

func (rows *Rows) Next() bool

func (*Rows) Scan

func (rows *Rows) Scan(args ...interface{}) (err error)

type SessionClaims

type SessionClaims struct {
	JWTClaims
	UserDesc   string `json:"userdesc"`
	IsSysAdmin bool   `json:"issysadmin"`
}

type StructDetails_Options

type StructDetails_Options int
const (
	SD_None                              = 0
	SD_Perms_Check StructDetails_Options = 0 << iota
	SD_Perms_Ignore
	SD_Tags_Require
	SD_Tags_Ignore
)

type StructOp

type StructOp uint
const (
	STRUCTOP_SET    StructOp = iota /* Set the item */
	STRUCTOP_ADD                    /* Add the item */
	STRUCTOP_REMOVE                 /* Remove the item */
)

type Token

type Token struct {
	*jwt.Token
}

func Token_New

func Token_New(ttype string, username string, expmins time.Duration, claims JWTClaimI) (token *Token)

func (*Token) GetClaims

func (tok *Token) GetClaims() JWTClaimI

func (*Token) Sign

func (token *Token) Sign() (tok string, err error)

type Tx

type Tx struct {
	*sql.Tx
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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