add data-fields and -values to shape:record; use for auth:principal
This commit is contained in:
parent
a81cc92097
commit
8f418400aa
4 changed files with 25 additions and 13 deletions
|
@ -53,8 +53,8 @@
|
||||||
(default-actions :reader default-actions :initform nil)
|
(default-actions :reader default-actions :initform nil)
|
||||||
(services :reader services :initform (make-hash-table))))
|
(services :reader services :initform (make-hash-table))))
|
||||||
|
|
||||||
(defun default-setup (cfg &optional (cls 'context))
|
(defun default-setup (cfg &optional (cls 'context) &rest args &key &allow-other-keys)
|
||||||
(make-instance cls :config cfg :name (config:name cfg)))
|
(apply #'make-instance cls :config cfg :name (config:name cfg) args))
|
||||||
|
|
||||||
(defun find-service (name &optional (parent *root*))
|
(defun find-service (name &optional (parent *root*))
|
||||||
(with-slots (services) parent
|
(with-slots (services) parent
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:config :scopes/config)
|
(:local-nicknames (:config :scopes/config)
|
||||||
(:core :scopes/core)
|
(:core :scopes/core)
|
||||||
|
(:shape :scopes/shape)
|
||||||
(:util :scopes/util))
|
(:util :scopes/util))
|
||||||
(:export #:config #:setup
|
(:export #:config #:setup
|
||||||
#:simple-credentials
|
#:simple-credentials
|
||||||
|
@ -15,10 +16,11 @@
|
||||||
((admin-credentials :reader admin-credentials :initarg :admin-credentials)))
|
((admin-credentials :reader admin-credentials :initarg :admin-credentials)))
|
||||||
|
|
||||||
(defclass context (core:context)
|
(defclass context (core:context)
|
||||||
((authenticator :initform (make-instance 'simple-authenticator))))
|
((authenticator :initarg :authenticator)))
|
||||||
|
|
||||||
(defun setup (cfg)
|
(defun setup (cfg)
|
||||||
(let* ((ctx (core:default-setup cfg 'context)))
|
(let* ((auth (make-instance 'simple-authenticator))
|
||||||
|
(ctx (core:default-setup cfg 'context :authenticator auth)))
|
||||||
ctx))
|
ctx))
|
||||||
|
|
||||||
;;;; simple / basic auth service implementation
|
;;;; simple / basic auth service implementation
|
||||||
|
@ -30,12 +32,9 @@
|
||||||
((login-name)
|
((login-name)
|
||||||
(password)))
|
(password)))
|
||||||
|
|
||||||
(defclass principal ()
|
(defclass principal (shape:record)
|
||||||
((identifier)
|
((shape:head-fields :initform '(:organization :short-name))
|
||||||
(credentials)
|
(shape:data-fields :initform '(:credentials :full-name :email :role))))
|
||||||
(full-name)
|
|
||||||
(primary-address)
|
|
||||||
(primary-role)))
|
|
||||||
|
|
||||||
(defun authenticate (cred)
|
(defun authenticate (cred)
|
||||||
(make-instance 'principal))
|
(make-instance 'principal))
|
||||||
|
|
|
@ -3,20 +3,27 @@
|
||||||
(defpackage :scopes/shape
|
(defpackage :scopes/shape
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:util :scopes/util))
|
(:local-nicknames (:util :scopes/util))
|
||||||
(:export #:record #:head-fields #:head #:head-value #:data
|
(:export #:record
|
||||||
#:head-plist))
|
#:head-fields #:head #:head-value #:head-plist
|
||||||
|
#:data-fields #:data #:data-value))
|
||||||
|
|
||||||
(in-package :scopes/shape)
|
(in-package :scopes/shape)
|
||||||
|
|
||||||
(defclass record ()
|
(defclass record ()
|
||||||
((head-fields :reader head-fields :initarg :head-fields
|
((head-fields :reader head-fields :initarg :head-fields
|
||||||
:initform '(:taskid :username) :allocation :class)
|
:initform '(:taskid :username) :allocation :class)
|
||||||
|
(data-fields :reader data-fields :initarg :data-fields
|
||||||
|
:initform nil :allocation :class)
|
||||||
(head :reader head :initarg :head)
|
(head :reader head :initarg :head)
|
||||||
(data :accessor data :initarg :data :initform nil)))
|
(data :accessor data :initarg :data :initform nil)))
|
||||||
|
|
||||||
(defmethod initialize-instance :after ((rec record) &key head &allow-other-keys)
|
(defmethod initialize-instance :after ((rec record) &key head &allow-other-keys)
|
||||||
(setf (slot-value rec 'head) (util:rfill (head-fields rec) head)))
|
(setf (slot-value rec 'head) (util:rfill (head-fields rec) head)))
|
||||||
|
|
||||||
|
(defmethod print-object ((rec record) stream)
|
||||||
|
(print-unreadable-object (rec stream :type t :identity t)
|
||||||
|
(format stream "~s <data ~s>" (head rec) (data rec))))
|
||||||
|
|
||||||
(defun head-value (rec key)
|
(defun head-value (rec key)
|
||||||
(elt (head rec) (position key (head-fields rec))))
|
(elt (head rec) (position key (head-fields rec))))
|
||||||
|
|
||||||
|
@ -28,3 +35,9 @@
|
||||||
(dolist (hf (head-fields rec))
|
(dolist (hf (head-fields rec))
|
||||||
(setf pl (cons hf (cons (util:keyword-to-string (pop hv)) pl))))
|
(setf pl (cons hf (cons (util:keyword-to-string (pop hv)) pl))))
|
||||||
pl))
|
pl))
|
||||||
|
|
||||||
|
(defun data-value (rec key)
|
||||||
|
(getf (data rec) key))
|
||||||
|
|
||||||
|
(defun (setf data-value) (val rec key)
|
||||||
|
(setf (getf (data rec) key) val))
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
((listener :accessor listener)))
|
((listener :accessor listener)))
|
||||||
|
|
||||||
(defun setup (cfg)
|
(defun setup (cfg)
|
||||||
(let ((ctx (make-instance 'context :config cfg :name (config:name cfg))))
|
(let ((ctx (core:default-setup cfg 'context)))
|
||||||
(start ctx)))
|
(start ctx)))
|
||||||
|
|
||||||
;;;; listener = server process
|
;;;; listener = server process
|
||||||
|
|
Loading…
Add table
Reference in a new issue