fn new #
fn new(config DBBackendConfig) !Authorizer
type UserID #
type UserID = string
enum AccessType #
enum AccessType {
read
write
}
struct AccessControlEntry #
struct AccessControlEntry {
id string // identifier of the user or role accessing the asset
asset_id string
permissions int
}
struct AccessControlList #
struct AccessControlList {
entries map[string]AccessControlEntry
}
struct AccessRequest #
struct AccessRequest {
accessor UserID // user requesting access to asset
asset_id string // id of the asset being accessed
access_type int // type of access being requested
}
struct Accessor #
struct Accessor {
id UserID
roles []Role
}
struct Asset #
struct Asset {
id string @[primary]
permissions int
acl []AccessControlEntry @[fkey: 'asset_id']
}
struct Authorizer #
struct Authorizer {
// roles map[string]Role
// mu t:
// assets map[string]Asset // assets mapped by their id
// admins []UserID // list of users which are admins
mut:
db sqlite.DB
// logger &log.Logger = &log.Logger(&log.Log{
// level: .debug
// })
}
fn (Authorizer) add_admin #
fn (mut a Authorizer) add_admin(id string)
fn (Authorizer) add_access_control #
fn (mut a Authorizer) add_access_control(asset Asset) !
struct Client #
struct Client {
url string
}
fn (Client) add_admin #
fn (c Client) add_admin(user_id string) !
struct Controller #
struct Controller {
vweb.Context
pub mut:
db sqlite.DB
}
fn (Controller) before_request #
fn (mut ctrl Controller) before_request()
struct DBBackendConfig #
@[params]
struct DBBackendConfig {
db_path string = 'authorization.sqlite'
mut:
db sqlite.DB
logger &log.Logger = &log.Logger(&log.Log{
level: .info
})
}
struct Role #
struct Role {
id string
members []UserID
}