pitchforkui

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: 24 Imported by: 4

Documentation

Index

Constants

View Source
const (
	StatusMovedPermanently    = http.StatusMovedPermanently    /* 301 */
	StatusFound               = http.StatusFound               /* 302 */
	StatusSeeOther            = http.StatusSeeOther            /* 303 */
	StatusBadRequest          = http.StatusBadRequest          /* 400 */
	StatusUnauthorized        = http.StatusUnauthorized        /* 401 */
	StatusForbidden           = http.StatusForbidden           /* 403 */
	StatusNotFound            = http.StatusNotFound            /* 404*/
	StatusInternalServerError = http.StatusInternalServerError /* 500 */
	StatusNotImplemented      = http.StatusNotImplemented      /* 501 */
	StatusServiceUnavailable  = http.StatusServiceUnavailable  /* 503 */
)

Aliases

View Source
const (
	PERM_NOTHING        = pf.PERM_NOTHING
	PERM_NONE           = pf.PERM_NONE
	PERM_GUEST          = pf.PERM_GUEST
	PERM_USER           = pf.PERM_USER
	PERM_USER_SELF      = pf.PERM_USER_SELF
	PERM_USER_NOMINATE  = pf.PERM_USER_NOMINATE
	PERM_USER_VIEW      = pf.PERM_USER_VIEW
	PERM_GROUP_MEMBER   = pf.PERM_GROUP_MEMBER
	PERM_GROUP_ADMIN    = pf.PERM_GROUP_ADMIN
	PERM_GROUP_WIKI     = pf.PERM_GROUP_WIKI
	PERM_GROUP_FILE     = pf.PERM_GROUP_FILE
	PERM_GROUP_CALENDAR = pf.PERM_GROUP_CALENDAR
	PERM_SYS_ADMIN      = pf.PERM_SYS_ADMIN
	PERM_SYS_ADMIN_CAN  = pf.PERM_SYS_ADMIN_CAN
	PERM_CLI            = pf.PERM_CLI
	PERM_API            = pf.PERM_API
	PERM_OAUTH          = pf.PERM_OAUTH
	PERM_LOOPBACK       = pf.PERM_LOOPBACK
	PERM_HIDDEN         = pf.PERM_HIDDEN
	PERM_NOCRUMB        = pf.PERM_NOCRUMB
	PERM_NOSUBS         = pf.PERM_NOSUBS
	PERM_NOBODY         = pf.PERM_NOBODY
)

Keep in sync with lib/ctx

View Source
const CSRF_TOKENNAME = "pfCSRF"
View Source
const PFFORM_READONLY = "readonly"

Variables

View Source
var ErrInvalidCSRF = errors.New("Invalid CSRF Token")
View Source
var ErrMissingValue = errors.New("Missing value")
View Source
var ErrNoRows = pf.ErrNoRows

Import this to avoid having to type too much

View Source
var ErrNotPOST = errors.New("Not a POST request")

Constants

View Source
var G_cookie_name = "_pitchfork"

Name of the cookies we set

Functions

func Csrf_token

func Csrf_token(method string, hostname string, path string, url string, username string) (string, string)

func FileUIApplyModOpts

func FileUIApplyModOpts(cui PfUI, file *pf.PfFile)

func FileUIApplyModOptsM

func FileUIApplyModOptsM(cui PfUI, files []pf.PfFile)

func H_NoAccess

func H_NoAccess(cui PfUI)

func H_errmsg

func H_errmsg(cui PfUI, err error)

func H_errmsgs

func H_errmsgs(cui PfUI, msg []string)

* Error messages * * Human readable, not computer thus with 200 OK

func H_error

func H_error(cui PfUI, status int)

* Error page generator * nginx should catch these though

func H_errtxt

func H_errtxt(cui PfUI, txt string)

func H_file

func H_file(cui PfUI)

func H_file_list_file

func H_file_list_file(cui PfUI)

func H_group_member_profile

func H_group_member_profile(cui PfUI)

func H_msg

func H_msg(cui PfUI)

func H_user_pwreset

func H_user_pwreset(cui PfUI)

func H_wiki

func H_wiki(cui PfUI)

func LogAccess_start

func LogAccess_start() (err error)

func LogAccess_stop

func LogAccess_stop()

func NewlineBR

func NewlineBR(val string) (safe template.HTML)

func Setup

func Setup(toolname string, securecookies bool) (err error)

func TFErr

func TFErr(cui PfUI, str string) (o string, buttons string, neditable int, subs []string, multipart bool)

func UIInit

func UIInit(securecookies bool, cookie_name string) error

func WikiUI_ApplyModOpts

func WikiUI_ApplyModOpts(cui PfUI, wiki *pf.PfWikiPage)

func WikiUI_ApplyModOptsMulti

func WikiUI_ApplyModOptsMulti(cui PfUI, wikis []pf.PfWikiPage)

Types

type CSRFClaims

type CSRFClaims struct {
	pf.JWTClaims
	Method string `json:"method"`
	Host   string `json:"host"`
	Path   string `json:"path"`
}
type PfLink struct {
	Link string
	Desc string
	Long string
	Subs []PfLink
}

func (PfLink) HTML

func (l PfLink) HTML() (s template.HTML)

type PfLinkCol

type PfLinkCol struct {
	M []PfLink
}

func (*PfLinkCol) Add

func (c *PfLinkCol) Add(l PfLink)

func (PfLinkCol) HTML

func (c PfLinkCol) HTML(ul bool, class string) (s template.HTML)

func (*PfLinkCol) Last

func (c *PfLinkCol) Last() (l *PfLink)

func (*PfLinkCol) Len

func (c *PfLinkCol) Len() int

func (*PfLinkCol) Pop

func (c *PfLinkCol) Pop() (l *PfLink)

type PfLoginPage

type PfLoginPage struct {
	*PfPage
	Login login
}

type PfNewUI

type PfNewUI func() (cui PfUI)

Types

type PfPage

type PfPage struct {
	URL              string
	Title            string
	PageTitle        string
	Menu             PfLinkCol
	SubMenu          PfLinkCol
	Crumbs           PfLinkCol
	LogoImg          string
	HeaderImg        string
	AdminName        string
	AdminEmail       string
	AdminEmailPublic bool
	CopyYears        string
	TheUser          *pf.PfUser
	NoIndex          bool
	CSS              []string
	Javascript       []string
	SysName          string
	Version          string
	PublicURL        string
	PeopleDomain     string
	RenderStamp      string
	UI               PfUI
}

func (*PfPage) AddCSS

func (p *PfPage) AddCSS(css string)

func (*PfPage) AddJS

func (p *PfPage) AddJS(js string)

type PfRootUI

type PfRootUI interface {
	H_root(w http.ResponseWriter, r *http.Request)
}

func NewPfRootUI

func NewPfRootUI(newui PfNewUI) (o PfRootUI)

type PfRootUIS

type PfRootUIS struct {
	PfRootUI
	// contains filtered or unexported fields
}

func (*PfRootUIS) H_root

func (o *PfRootUIS) H_root(w http.ResponseWriter, r *http.Request)

Root page -- where Go's net/http gives it to us

func (*PfRootUIS) New

func (o *PfRootUIS) New() PfUI

type PfUI

type PfUI interface {
	pf.PfCtx
	PfUIi
}

func NewPfUI

func NewPfUI(ctx pf.PfCtx, mainmenuoverride PfUIMenuI, submenuoverride PfUIMenuI, uiloginoverride PfUILoginI) (cui PfUI)

Functions

type PfUIFunc

type PfUIFunc func(cui PfUI)

type PfUILoginI

type PfUILoginI func(cui PfUI, lp *PfLoginPage) (p interface{}, err error)

type PfUIMentry

type PfUIMentry struct {
	URI   string
	Desc  string
	Perms pf.Perm
	Fun   PfUIFunc
	Subs  []PfUIMentry
}

func NewPfUIMentry

func NewPfUIMentry(URI string, Desc string, Perms pf.Perm, Fun PfUIFunc) PfUIMentry

type PfUIMenu

type PfUIMenu struct {
	M []PfUIMentry
}

func NewPfUIMenu

func NewPfUIMenu(m []PfUIMentry) PfUIMenu

Functions

func (*PfUIMenu) Add

func (menu *PfUIMenu) Add(m ...PfUIMentry)

Add a menu item (to the end of the menu)

func (*PfUIMenu) AddPerms

func (menu *PfUIMenu) AddPerms(uri string, perms pf.Perm)

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

func (*PfUIMenu) DelPerms

func (menu *PfUIMenu) DelPerms(uri string, perms pf.Perm)

And new permissions into it, useful to remove permissions

func (*PfUIMenu) Filter

func (menu *PfUIMenu) Filter(allowedURI []string)

Filter menu items only leaving the URIs in allowedURI

func (*PfUIMenu) Remove

func (menu *PfUIMenu) Remove(uri string)

Remove an item from the menu

func (*PfUIMenu) Replace

func (menu *PfUIMenu) Replace(uri string, fun PfUIFunc)

Replace a menu item

func (*PfUIMenu) SetPerms

func (menu *PfUIMenu) SetPerms(uri string, perms pf.Perm)

Override the permissions of a menu item, useful to change the full permission

func (*PfUIMenu) ToLinkCol

func (menu *PfUIMenu) ToLinkCol(cui PfUI, depth int) (links PfLinkCol)

func (*PfUIMenu) ToLinkColPfx

func (menu *PfUIMenu) ToLinkColPfx(cui PfUI, depth int, pfx string) (links PfLinkCol)

type PfUIMenuI

type PfUIMenuI func(cui PfUI, menu *PfUIMenu)

type PfUIS

type PfUIS struct {
	pf.PfCtx /* Pitchfork Context (not really embedded, a pointer) */
	// contains filtered or unexported fields
}

func (*PfUIS) AddCrumb

func (cui *PfUIS) AddCrumb(link string, desc string, long string)

func (*PfUIS) AddHeader

func (cui *PfUIS) AddHeader(h string, v string)

func (*PfUIS) DelCrumb

func (cui *PfUIS) DelCrumb() (link string, desc string, long string)

func (*PfUIS) Flush

func (cui *PfUIS) Flush()

func (*PfUIS) FormValue

func (cui *PfUIS) FormValue(key string) (val string, err error)

* Gets argument from POST values only - mandatory CSRF check * The function to use for single items

func (*PfUIS) FormValueM

func (cui *PfUIS) FormValueM(key string) (vals []string, err error)

* Gets argument from POST values only - mandatory CSRF check * The function to use for multiple returns (eg a map)

func (*PfUIS) FormValueNoCSRF

func (cui *PfUIS) FormValueNoCSRF(key string) (val string, err error)

* Gets argument from POST values only - skip CSRF check * * *AVOID* using this as much as possible: only when known that an * outside thing might do a direct POST. * * Currently that is only the Oauth2 code.

func (*PfUIS) GetArg

func (cui *PfUIS) GetArg(key string) (val string)

func (*PfUIS) GetArgCSRF

func (cui *PfUIS) GetArgCSRF(key string) (val string)

Force a CSRF check

func (*PfUIS) GetBody

func (cui *PfUIS) GetBody() (body []byte)

func (*PfUIS) GetCrumbParts

func (cui *PfUIS) GetCrumbParts() (path []string)

func (*PfUIS) GetCrumbPath

func (cui *PfUIS) GetCrumbPath() (path string)

func (*PfUIS) GetFormFile

func (cui *PfUIS) GetFormFile(key string, maxsize string, b64 bool) (val string, err error)

Returns a base64 encoded representation of a file

func (*PfUIS) GetFormFileReader

func (cui *PfUIS) GetFormFileReader(key string) (file io.ReadCloser, filename string, err error)

func (*PfUIS) GetFullPath

func (cui *PfUIS) GetFullPath() (path string)

func (*PfUIS) GetFullURL

func (cui *PfUIS) GetFullURL() (path string)

func (*PfUIS) GetHTTPHeader

func (cui *PfUIS) GetHTTPHeader(name string) (val string)

func (*PfUIS) GetHTTPHost

func (cui *PfUIS) GetHTTPHost() (host string)

func (*PfUIS) GetMethod

func (cui *PfUIS) GetMethod() (method string)

func (*PfUIS) GetPath

func (cui *PfUIS) GetPath() (path []string)

func (*PfUIS) GetPathString

func (cui *PfUIS) GetPathString() (path string)

func (*PfUIS) GetSubPath

func (cui *PfUIS) GetSubPath() (path string)

func (*PfUIS) HandleCmd

func (cui *PfUIS) HandleCmd(cmd string, args []string) (msg string, err error)

* Command handler - directly call a command with arguments * * Use this for form posts with specific parameters * The parameters are matched to the command

func (*PfUIS) HandleForm

func (cui *PfUIS) HandleForm(cmd string, args []string, obj interface{}) (msg string, err error)

* Form handler - called for form submissions * * Use this in combination with 'object set <form-element> <value>' style commands * For each matching form-element (name) the command is executed

func (*PfUIS) HandleFormS

func (cui *PfUIS) HandleFormS(cmd string, autoop bool, args []string, obj interface{}) (msg string, err error)

* When autoop is false, the operand is already in the 'cmd'. * * When autoop is true, we determine the op based on the 'submit' button. * When 'submit' is 'Add'/'Remove' the op becomes that and in lowercase * appended to the cmd. * * When autoop is true, we ignore slices unless the op is add or remove.

func (*PfUIS) InitToken

func (cui *PfUIS) InitToken()

func (*PfUIS) IsGET

func (cui *PfUIS) IsGET() (isget bool)

func (*PfUIS) IsPOST

func (cui *PfUIS) IsPOST() (ispost bool)

func (*PfUIS) JSONAnswer

func (cui *PfUIS) JSONAnswer(status string, message string)

func (*PfUIS) MenuPath

func (cui *PfUIS) MenuPath(menu PfUIMenu, path *[]string)

func (*PfUIS) NoSubs

func (cui *PfUIS) NoSubs() bool

For when there are no more specific URLs

func (*PfUIS) OutUnbuffered

func (cui *PfUIS) OutUnbuffered(txt string)

func (*PfUIS) Page_def

func (cui *PfUIS) Page_def() (p *PfPage)

func (*PfUIS) Page_show

func (cui *PfUIS) Page_show(name string, data interface{})

func (*PfUIS) ParseClientIP

func (cui *PfUIS) ParseClientIP(remaddr string, xff string, xffc []*net.IPNet) (ip net.IP, addr string, err error)

* Note: addr will always contain the full XFF * as received, but only the right hand side will be valid * we do not discard the components that are untrusted * as they might have forensic value * * The 'ip' returned is the trusted value though

func (*PfUIS) QueryArgSet

func (cui *PfUIS) QueryArgSet(q string) (ok bool)

func (*PfUIS) SetBearerAuth

func (cui *PfUIS) SetBearerAuth(t bool)

func (*PfUIS) SetClientIP

func (cui *PfUIS) SetClientIP() (err error)

func (*PfUIS) SetContentType

func (cui *PfUIS) SetContentType(ctype string)

func (*PfUIS) SetExpired

func (cui *PfUIS) SetExpired()

func (*PfUIS) SetExpires

func (cui *PfUIS) SetExpires(minutes int)

func (*PfUIS) SetFileName

func (cui *PfUIS) SetFileName(fname string)

func (*PfUIS) SetHeader

func (cui *PfUIS) SetHeader(h string, v string)

func (*PfUIS) SetJSON

func (cui *PfUIS) SetJSON(json []byte)

func (*PfUIS) SetPageMenu

func (cui *PfUIS) SetPageMenu(menu *PfUIMenu)

func (*PfUIS) SetPath

func (cui *PfUIS) SetPath(path []string)

func (*PfUIS) SetRaw

func (cui *PfUIS) SetRaw(raw []byte)

func (*PfUIS) SetRedirect

func (cui *PfUIS) SetRedirect(path string, status int)

func (*PfUIS) SetStaticFile

func (cui *PfUIS) SetStaticFile(file string)

func (*PfUIS) SetSubPath

func (cui *PfUIS) SetSubPath(path string)

func (*PfUIS) UIInit

func (cui *PfUIS) UIInit(w http.ResponseWriter, r *http.Request) (err error)

func (*PfUIS) UIMainMenuOverride

func (cui *PfUIS) UIMainMenuOverride(menu *PfUIMenu)

func (*PfUIS) UIMenu

func (cui *PfUIS) UIMenu(menu PfUIMenu)

func (*PfUIS) UISubMenuOverride

func (cui *PfUIS) UISubMenuOverride(menu *PfUIMenu)

type PfUIi

type PfUIi interface {
	UIInit(w http.ResponseWriter, r *http.Request) (err error)
	FormValue(key string) (val string, err error)
	FormValueM(key string) (vals []string, err error)
	FormValueNoCSRF(key string) (val string, err error)
	GetMethod() (method string)
	IsGET() (isget bool)
	IsPOST() (ispost bool)
	GetHTTPHost() string
	GetHTTPHeader(name string) (val string)
	GetPath() (path []string)
	GetPathString() (path string)
	SetPath(path []string)
	GetSubPath() (path string)
	SetSubPath(path string)
	GetFullPath() (path string)
	GetFullURL() (path string)
	GetArg(key string) (val string)
	GetArgCSRF(key string) (val string)
	ParseClientIP(remaddr string, xff string, xffc []*net.IPNet) (ip net.IP, addr string, err error)
	NoSubs() bool
	SetClientIP() (err error)
	SetBearerAuth(t bool)
	AddHeader(h string, v string)
	SetHeader(h string, v string)
	Flush()
	SetExpired()
	SetExpires(minutes int)
	SetContentType(ctype string)
	SetFileName(fname string)
	SetStaticFile(file string)
	SetRaw(raw []byte)
	SetJSON(json []byte)
	JSONAnswer(status string, message string)
	AddCrumb(link string, desc string, long string)
	DelCrumb() (link string, desc string, long string)
	GetCrumbPath() (path string)
	GetCrumbParts() (path []string)
	Page_def() (p *PfPage)
	Page_show(name string, data interface{})

	SetRedirect(path string, status int)
	GetBody() (body []byte)
	GetFormFileReader(key string) (file io.ReadCloser, filename string, err error)
	GetFormFile(key string, maxsize string, b64 bool) (val string, err error)
	QueryArgSet(q string) (ok bool)
	HandleForm(cmd string, args []string, obj interface{}) (msg string, err error)
	HandleFormS(cmd string, autoop bool, args []string, obj interface{}) (msg string, err error)
	HandleCmd(cmd string, args []string) (msg string, err error)
	SetPageMenu(menu *PfUIMenu)
	MenuPath(menu PfUIMenu, path *[]string)
	UIMenu(menu PfUIMenu)
	InitToken()
	// contains filtered or unexported methods
}

type PfUserDetailForm

type PfUserDetailForm struct {
	Type   string `label:"Detail Type" pfreq:"yes" hint:"Select the detail you would like to set" options:"GetTypeOpts"`
	Value  string `label:"Value" pfreq:"yes" hint:"Value of the detail"`
	Button string `label:"Add Detail" pftype:"submit"`
}

func NewPfUserDetailForm

func NewPfUserDetailForm() (df *PfUserDetailForm)

func (*PfUserDetailForm) GetTypeOpts

func (df *PfUserDetailForm) GetTypeOpts(obj interface{}) (kvs keyval.KeyVals, err error)

type PfUserLanguageForm

type PfUserLanguageForm struct {
	Language string `label:"Language" pfreq:"yes" hint:"Select the language to add" options:"GetLanguageOpts"`
	Skill    string `label:"Skill Level" pfreq:"yes" hint:"Select the appropriate skill level" options:"GetSkillOpts"`
	Button   string `label:"Add Language" pftype:"submit"`
}

func NewPfUserLanguageForm

func NewPfUserLanguageForm() (lf *PfUserLanguageForm)

func (*PfUserLanguageForm) GetLanguageOpts

func (lf *PfUserLanguageForm) GetLanguageOpts(obj interface{}) (kvs keyval.KeyVals, err error)

func (*PfUserLanguageForm) GetSkillOpts

func (n *PfUserLanguageForm) GetSkillOpts(obj interface{}) (kvs keyval.KeyVals, err error)

type TFATok

type TFATok struct {
	CurPassword string `label:"Current Password" pfreq:"yes" hint:"Your current password" pftype:"password"`
	Descr       string `label:"Description" pfreq:"yes" hint:"iPhone, Android etc."`
	Type        string `label:"OTP Type" pfreq:"yes" hint:"The Two Factor Token Type" options:"GetTypeOpts"`
	Button      string `label:"Create" pftype:"submit"`
	// contains filtered or unexported fields
}

func NewTFATok

func NewTFATok(cui PfUI) (tok *TFATok)

func (*TFATok) GetTypeOpts

func (tok *TFATok) GetTypeOpts(obj interface{}) (kvs keyval.KeyVals, err error)

func (*TFATok) ObjectContext

func (tok *TFATok) ObjectContext() (obj interface{})

type VerifiedEM

type VerifiedEM struct {
	Action     string `label:"set" pftype:"hidden"`
	EmailAddr  string `label:"Email Address" pfreq:"yes" pfset:"user" hint:"Select the address to use for this group" options:"GetEmailOpts"`
	GroupName  string `label:"groupname" pftype:"hidden"`
	GroupDesc  string `label:"groupdesc" pftype:"hidden"`
	GroupState string `label:"groupstate" pftype:"hidden"`
	Button     string `label:"Select Address" pftype:"submit"`
	// contains filtered or unexported fields
}

func (VerifiedEM) GetEmailOpts

func (vem VerifiedEM) GetEmailOpts(obj interface{}) (kvs keyval.KeyVals, err error)

func (VerifiedEM) ObjectContext

func (vem VerifiedEM) ObjectContext() (obj interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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