summaryrefslogtreecommitdiffstats
path: root/acf/modules/aaa.lua
blob: e98e6866a817684aba3a1c873111ec52d83de0df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--[[
Copyright (c) 2012-2013 Kaarle Ritvanen
See LICENSE file for license details
--]]

module(..., package.seeall)

local M = require('acf.model')

Role = M.new()
Role.permissions = M.Set{type=M.Reference{scope='../../../permissions'}}

User = M.new()
User.password = M.String
User.real_name = M.String
User.roles = M.Set{type=M.Reference{scope='../../../roles'}}
function User:check_password(password) return password == self.password end

Authentication = M.new()
Authentication.users = M.Collection{type=User}
Authentication.roles = M.Collection{type=Role}
Authentication.permissions = M.Set{type=M.String}

M.register('auth',
	   '/json'..require('lfs').currentdir()..'/config/aaa.json',
	   Authentication)