Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the can Reference Manual, version 0.1, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 10:51:38 2018 GMT+0.
• Introduction: | What can is all about | |
• Systems: | The systems documentation | |
• Modules: | The modules documentation | |
• Files: | The files documentation | |
• Packages: | The packages documentation | |
• Definitions: | The symbols documentation | |
• Indexes: | Concepts, functions, variables and data types |
Can is a role-based access right control library.
(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
(ql:quickload :can)
Copyright (c) 2016 Eitaro Fukamachi (e.arrows@gmail.com)
Licensed under the BSD 2-Clause License.
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The can system: |
Eitaro Fukamachi
BSD 2-Clause
A role-based access right control library
# 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
can.asd (file)
src (module)
Modules are listed depth-first from the system components tree.
• The can/src module: |
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files: |
• The can.asd file: | ||
• The can/src/can.lisp file: |
Next: The can/src/can<dot>lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
Previous: The can<dot>asd file, Up: Lisp files [Contents][Index]
src (module)
src/can.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The can-asd package: | ||
• The can package: |
Next: The can package, Previous: Packages, Up: Packages [Contents][Index]
can.asd
Previous: The can-asd package, Up: Packages [Contents][Index]
can.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions: |
Previous: Definitions, Up: Definitions [Contents][Index]
• Exported functions: | ||
• Exported generic functions: |
Next: Exported generic functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Previous: Exported functions, Up: Exported definitions [Contents][Index]
Previous: Definitions, Up: Top [Contents][Index]
• Concept index: | ||
• Function index: | ||
• Variable index: | ||
• Data type index: |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L M |
---|
Jump to: | C F L M |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | C F G M R U |
---|
Jump to: | C F G M R U |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
C | |||
can : | The can system | ||
can : | The can package | ||
can-asd : | The can-asd package | ||
| |||
P | |||
Package, can : | The can package | ||
Package, can-asd : | The can-asd package | ||
| |||
S | |||
System, can : | The can system | ||
|
Jump to: | C P S |
---|