The can Reference Manual

This is the can Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 14:48:35 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 can

A role-based access right control library

Author

Eitaro Fukamachi

License

BSD 2-Clause

Long Description

# 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.

Version

0.1

Source

can.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


3.1 can/src

Source

can.asd.

Parent Component

can (system).

Child Component

can.lisp (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 can/can.asd

Source

can.asd.

Parent Component

can (system).

ASDF Systems

can.

Packages

can-asd.


4.1.2 can/src/can.lisp

Source

can.asd.

Parent Component

src (module).

Packages

can.

Public Interface

5 Packages

Packages are listed by definition order.


5.1 can

Source

can.lisp.

Use List

common-lisp.

Public Interface

5.2 can-asd

Source

can.asd.

Use List
  • asdf/interface.
  • common-lisp.

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Ordinary functions

Function: can (user action resource)
Package

can.

Source

can.lisp.

Function: rolep (user role &key test)
Package

can.

Source

can.lisp.


6.1.2 Generic functions

Generic Function: resource-allowed-p (resource action role)
Package

can.

Source

can.lisp.

Methods
Method: resource-allowed-p (resource action role)
Generic Function: user-roles (user)
Package

can.

Source

can.lisp.

Methods
Method: user-roles (user)
Generic Function: user-roles-for-resource (user resource)
Package

can.

Source

can.lisp.

Methods
Method: user-roles-for-resource (user resource)

Appendix A Indexes


A.1 Concepts


A.3 Variables