The can Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The can Reference Manual

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.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Can

Can is a role-based access right control library.

Usage

(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

(ql:quickload :can)

Author

Copyright

Copyright (c) 2016 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the BSD 2-Clause License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

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


Previous: , Up: Systems   [Contents][Index]

2.1 can

Author

Eitaro Fukamachi

License

BSD 2-Clause

Description

A role-based access right control library

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 (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

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


Previous: , Up: Modules   [Contents][Index]

3.1 can/src

Parent

can (system)

Location

src/

Component

can.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

4 Files

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


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 can.asd

Location

can.asd

Systems

can (system)

Packages

can-asd


Previous: , Up: Lisp files   [Contents][Index]

4.1.2 can/src/can.lisp

Parent

src (module)

Location

src/can.lisp

Packages

can

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 can-asd

Source

can.asd

Use List

Previous: , Up: Packages   [Contents][Index]

5.2 can

Source

can.lisp (file)

Use List

common-lisp

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

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


Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Functions

Function: can USER ACTION RESOURCE
Package

can

Source

can.lisp (file)

Function: rolep USER ROLE &key TEST
Package

can

Source

can.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Generic functions

Generic Function: resource-allowed-p RESOURCE ACTION ROLE
Package

can

Source

can.lisp (file)

Methods
Method: resource-allowed-p RESOURCE ACTION ROLE
Generic Function: user-roles USER
Package

can

Source

can.lisp (file)

Methods
Method: user-roles USER
Generic Function: user-roles-for-resource USER RESOURCE
Package

can

Source

can.lisp (file)

Methods
Method: user-roles-for-resource USER RESOURCE

Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L   M  
Index Entry  Section

C
can.asd: The can<dot>asd file
can/src: The can/src module
can/src/can.lisp: The can/src/can<dot>lisp file

F
File, Lisp, can.asd: The can<dot>asd file
File, Lisp, can/src/can.lisp: The can/src/can<dot>lisp file

L
Lisp File, can.asd: The can<dot>asd file
Lisp File, can/src/can.lisp: The can/src/can<dot>lisp file

M
Module, can/src: The can/src module

Jump to:   C   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   F   G   M   R   U  
Index Entry  Section

C
can: Exported functions

F
Function, can: Exported functions
Function, rolep: Exported functions

G
Generic Function, resource-allowed-p: Exported generic functions
Generic Function, user-roles: Exported generic functions
Generic Function, user-roles-for-resource: Exported generic functions

M
Method, resource-allowed-p: Exported generic functions
Method, user-roles: Exported generic functions
Method, user-roles-for-resource: Exported generic functions

R
resource-allowed-p: Exported generic functions
resource-allowed-p: Exported generic functions
rolep: Exported functions

U
user-roles: Exported generic functions
user-roles: Exported generic functions
user-roles-for-resource: Exported generic functions
user-roles-for-resource: Exported generic functions

Jump to:   C   F   G   M   R   U  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

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