This is the can Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 04:29:40 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
can
A role-based access right control library
Eitaro Fukamachi
BSD 2-Clause
# Can
Can is a role-based access right control library.
## Usage
“‘common-lisp
(defclass user () ()
(:metaclass mito:dao-table-class))
(defclass user-role ()
((user :col-type user
:initarg :user
:accessor user-role-user)
(role :col-type (:varchar 50)
:initarg :role
:inflate (compose #’make-keyword #’string-upcase)
:deflate #’string-downcase
:accessor user-role-role))
(:metaclass mito:dao-table-class)
(:primary-key user role)
(:auto-pk nil)
(:record-timestamps nil))
;; Retrieving roles from "user-role" table
(defmethod user-roles ((user user))
(mapcar #’user-role-role
(mito:retrieve-dao ’user-role :user user)))
(defclass entry ()
((author :col-type user
:initarg :author
:accessor entry-author))
(:metaclass mito:dao-table-class))
;; Return (:owner) if the user is an author of the entry
(defmethod user-roles-for-resource ((user user) (resource entry))
(cond
((object= user (entry-author resource))
(list :owner))
(t
nil)))
;; All users can see the entry
(defmethod resource-allowed-p ((resource entry) (action (eql :show)) role)
t)
;; Owner can edit the entry
(defmethod resource-allowed-p ((resource entry) (action (eql :edit)) (role (eql :owner)))
t)
;; Owner can delete the entry
(defmethod resource-allowed-p ((resource entry) (action (eql :delete)) (role (eql :owner)))
t)
(let* ((user (mito:find-dao ’user :id 1))
(entry (first (mito:retrieve-dao ’entry :author user))))
(can user :edit entry))
;=> T
“‘
## Installation
“‘common-lisp
(ql:quickload :can)
“‘
## Author
* Eitaro Fukamachi (e.arrows@gmail.com)
## Copyright
Copyright (c) 2016 Eitaro Fukamachi (e.arrows@gmail.com)
## License
Licensed under the BSD 2-Clause License.
0.1
src
(module).
Modules are listed depth-first from the system components tree.
Files are sorted by type and then listed depth-first from the systems components trees.
can/src/can.lisp
src
(module).
can
.
can
(function).
resource-allowed-p
(generic function).
rolep
(function).
user-roles
(generic function).
user-roles-for-resource
(generic function).
Packages are listed by definition order.
can
common-lisp
.
can
(function).
resource-allowed-p
(generic function).
rolep
(function).
user-roles
(generic function).
user-roles-for-resource
(generic function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Jump to: | C F G M R U |
---|
Jump to: | C F G M R U |
---|
Jump to: | C F M P S |
---|
Jump to: | C F M P S |
---|