Skip to content

webserver.publisher2 #

fn get #

fn get() ?Publisher

install mdbook will return true if it was already installed

enum AccessStatus #

enum AccessStatus {
	no_access
	email_required
	auth_required
	ok
}

enum SiteType #

enum SiteType {
	book // mdbook
	wiki
	web // just html
}

struct ACE #

@[heap]
struct ACE {
pub mut:
	groups []&Group // pointer to the object as is in the publisher one
	users  []&User  // can be or a user or a group
	right  Right
}

Access Control Entry

struct ACL #

@[heap]
struct ACL {
pub mut:
	name    string
	entries []ACE
}

Access Control List

struct Access #

struct Access {
pub:
	right  Right
	status AccessStatus
}

struct AccessLog #

struct AccessLog {
	user User
	path Path
	time Time
}

struct Authentication #

@[heap]
struct Authentication {
pub mut:
	email_required      bool   // if true means users need to give their email address (just a form)
	email_authenticated bool   // if true, means user needs to give email address and verify the correctness with email client
	tfconnect           bool   // not used now for future
	kyc                 bool   // not used now for future (KYC/AML)
	acl                 []&ACL // list of people who have access, can be empty if empty there can be passwd
}

if acl not empty then is obliged to use, if email required email need to match USER and the ACE/ACL if in combination with email_authenticated, it means we make sure that email is correct, so becomes string in future will be compatible with TFConnect

struct Email #

struct Email {
pub mut:
	address       string
	authenticated bool
}

struct Group #

@[heap]
struct Group {
pub:
	name string
pub mut:
	users []&User
}

struct Publisher #

@[heap]
struct Publisher {
pub mut:
	// node  &builder.Node
	state  State
	sites  map[string]Site // the key is the prefix as used on webserver
	groups map[string]Group
	users  map[string]User
	acls   map[string]ACL
}

fn (Publisher) user_add #

fn (mut p Publisher) user_add(name_ string) &User

fn (Publisher) site_add #

fn (mut p Publisher) site_add(name_ string, type_ SiteType) &Site

pub fn (p Publisher) get_user_sites(user User)

fn (Publisher) acl_add #

fn (mut p Publisher) acl_add(name_ string) &ACL

fn (Publisher) site_acl_add #

fn (mut p Publisher) site_acl_add(site_ string, acl &ACL)

fn (Publisher) auth_add #

fn (mut p Publisher) auth_add(email_req bool, email_auth bool) &Authentication

fn (Publisher) get_sites_accessible #

fn (p Publisher) get_sites_accessible(username string) map[string]Site

returns the sites that the user has read or write access to

fn (Publisher) get_access #

fn (p Publisher) get_access(user User, sitename string) Access

? get highest or lowest right? returns the right a user has to a given authentication struct

fn (Publisher) ace_add #

fn (mut p Publisher) ace_add(acl string, right Right) &ACE

pub fn (mut p Publisher) ace_add(right Right, acl_name string) &ACE { ace := ACE{right: right} p.acls[acl_name].entries << ace return &ace }

fn (Publisher) ace_add_user #

fn (mut p Publisher) ace_add_user(mut ace ACE, user &User) &ACE

fn (Publisher) get_right #

fn (p Publisher) get_right(username string, sitename string) Right

? get highest or lowest right? returns the right a user has to a given authentication struct

struct Site #

@[heap]
struct Site {
pub:
	name      string // correspond to key, uses namefix from texttoolsmap[string]Page
	publisher &Publisher @[str: skip] // pointer to sites
	sitetype  SiteType
pub mut:
	path           Path // path where site can be found
	authentication Authentication
	logs           []AccessLog = []
}

fn (Site) auth_add #

fn (site Site) auth_add(email_required bool, email_authenticated bool, acl &ACL) &Authentication

struct User #

@[heap]
struct User {
pub:
	name string
pub mut:
	emails  []Email
	pubkeys []string // optional
	sshkeys []string // optional
}