Skip to content

webserver.heroweb #

fn model_auth_example #

fn model_auth_example() !

Example usage

fn new #

fn new(path string) !&App

the path is pointing to the instructions

enum InfoType #

enum InfoType {
	html
	slides
	pdf
	wiki
	website
}

enum RightEnum #

enum RightEnum {
	block
	read
	write
	admin
}

fn (RightEnum) level #

fn (r RightEnum) level() int

struct ACE #

struct ACE {
pub mut:
	group string
	user  u16
	right RightEnum
}

struct ACEAddArgs #

@[params]
struct ACEAddArgs {
pub mut:
	group string
	user  u16
	right RightEnum
}

struct ACL #

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

fn (ACL) add #

fn (mut self ACL) add(args ACEAddArgs) !ACE

struct ACLAddArgs #

@[params]
struct ACLAddArgs {
pub mut:
	name    string
	entries []ACE
}

struct App #

struct App {
	veb.StaticHandler
	veb.Middleware[Context]
	veb.Controller
	jwt_secret string = jwt.create_secret()
mut:
	db WebDB
pub:
	base_url   string = 'http://localhost:8090'
	secret_key string = '1234'
}

fn (App) asset #

fn (app &App) asset(mut ctx Context, paths string) veb.Result

this endpoint serves assets dynamically

fn (App) assets #

fn (mut app App) assets(mut ctx Context) veb.Result

fn (App) authentication_mail_sent #

fn (mut app App) authentication_mail_sent(mut ctx Context, email string) veb.Result

fn (App) callback #

fn (mut app App) callback(mut ctx Context, email string, expiration string, signature string) veb.Result

fn (App) index #

fn (app &App) index(mut ctx Context) veb.Result

fn (App) is_authorized #

fn (app App) is_authorized(mut ctx Context) bool

middleware to check if user is authorized to access an infopointer or asset

fn (App) is_logged_in #

fn (app App) is_logged_in(mut ctx Context) bool

middleware to set user id to context from jwt

fn (App) kanban #

fn (app &App) kanban(mut ctx Context) veb.Result

fn (App) log_post #

fn (mut app App) log_post(mut ctx Context, name string) veb.Result

fn (App) logs #

fn (mut app App) logs(mut ctx Context) veb.Result

fn (App) register #

fn (mut app App) register(mut ctx Context) veb.Result

fn (App) set_user #

fn (app App) set_user(mut ctx Context) bool

middleware to set user id to context from jwt

fn (App) signin #

fn (app &App) signin(mut ctx Context) veb.Result

fn (App) view #

fn (app &App) view(mut ctx Context) veb.Result

fn (App) view_asset #

fn (app &App) view_asset(mut ctx Context, name string) veb.Result

fn (App) view_assets #

fn (app &App) view_assets(mut ctx Context, name string) veb.Result

fn (App) view_logs #

fn (mut app App) view_logs(mut ctx Context) veb.Result

struct AuthorizationRequest #

struct AuthorizationRequest {
pub:
	right   RightEnum
	subject u16    // subject attempting to be authorized
	object  string // object for which authorization is being attempted
}

struct Context #

struct Context {
	veb.Context
pub mut:
	// In the context struct we store data that could be different
	// for each request. Like a User struct or a session id
	user_id    u16
	session_id string
}

struct Doc #

struct Doc {
pub mut:
	navbar   Navbar
	content  elements.Doc
	markdown MarkdownContent
	title    string
}

struct Group #

struct Group {
pub mut:
	name   string
	users  []u16
	groups []string
}

struct GroupAddArgs #

@[params]
struct GroupAddArgs {
pub mut:
	name     string
	user_ids []u16
	groups   string
}

struct InfoPointer #

struct InfoPointer {
pub mut:
	name            string
	path_content    string
	path_heroscript string
	children        []InfoPointer // e.g. to create a folder, there can be a folder in a folder too (but there it stops)
	acl             []string
	description     string
	expiration      string
	acl_resolved    map[u16]u8
	cat             InfoType
	// slides       ?SlidesViewData
	dagu bool // not used for now, is when we will run the hero actions in dagu
}

struct InfoPointerAddArgs #

@[params]
struct InfoPointerAddArgs {
pub mut:
	name            string
	path_content    string
	path_heroscript string
	cat             InfoType
	acl             []string
	description     string
	expiration      string
}

struct MarkdownContent #

struct MarkdownContent {
pub mut:
	nav     string
	content string
	title   string
}

struct ModelAuthNewArgs #

@[params]
struct ModelAuthNewArgs {
pub mut:
	heroscript string
}

struct Slides #

struct Slides {
pub:
	url          string
	name         string
	log_endpoint string
}

fn (Slides) html #

fn (slides Slides) html() string

struct User #

struct User {
pub mut:
	id          u16 // increment as we load it
	name        string
	email       []string
	description string
	profile     string
	admin       bool
}

struct UserAddArgs #

@[params]
struct UserAddArgs {
pub mut:
	name        string
	email       string
	description string
	profile     string
	admin       bool
}

struct WebDB #

struct WebDB {
	Logger
pub mut:
	authenticator StatelessAuthenticator
	users         map[u16]&User
	groups        map[string]&Group
	acls          map[string]&ACL
	infopointers  map[string]&InfoPointer
}

fn (WebDB) acl_add #

fn (mut self WebDB) acl_add(args_ ACLAddArgs) !&ACL

fn (WebDB) authorize #

fn (db WebDB) authorize(request AuthorizationRequest) !bool

fn (WebDB) authorized_ptrs #

fn (mut db WebDB) authorized_ptrs(subject u16, right RightEnum) ![]InfoPointer

fn (WebDB) get_user_id #

fn (self WebDB) get_user_id(user User) ?u16

fn (WebDB) group_add #

fn (mut self WebDB) group_add(args GroupAddArgs) !&Group

fn (WebDB) infopointer_add #

fn (mut self WebDB) infopointer_add(args InfoPointerAddArgs) !&InfoPointer

fn (WebDB) infopointer_resolve #

fn (db WebDB) infopointer_resolve(info_name string) !map[u16]u8

fn (WebDB) infopointer_run #

fn (mut db WebDB) infopointer_run(info_name string) !

run the heroscript

fn (WebDB) new_user #

fn (mut self WebDB) new_user(user User) u16

fn (WebDB) play_authentication #

fn (mut db WebDB) play_authentication(mut plbook playbook.PlayBook) !WebDB

fn (WebDB) play_authorization #

fn (mut db WebDB) play_authorization(mut plbook playbook.PlayBook) !WebDB

fn (WebDB) play_infopointers #

fn (mut db WebDB) play_infopointers(mut plbook playbook.PlayBook) !

fn (WebDB) register_login #

fn (mut self WebDB) register_login(email string) !u16

either registers user, or logs user in

fn (WebDB) user_add #

fn (mut self WebDB) user_add(args UserAddArgs) !u16