auth: minor steps toward setting up default (admin) principal
This commit is contained in:
parent
8f418400aa
commit
792a8c4c09
1 changed files with 9 additions and 5 deletions
|
@ -16,17 +16,19 @@
|
|||
((admin-credentials :reader admin-credentials :initarg :admin-credentials)))
|
||||
|
||||
(defclass context (core:context)
|
||||
((authenticator :initarg :authenticator)))
|
||||
((authenticator :reader authenticator :initarg :authenticator)))
|
||||
|
||||
(defun setup (cfg)
|
||||
(let* ((auth (make-instance 'simple-authenticator))
|
||||
(ctx (core:default-setup cfg 'context :authenticator auth)))
|
||||
(ctx (core:default-setup cfg 'context :authenticator auth))
|
||||
(cred (admin-credentials cfg)))
|
||||
(setf (gethash :admin (principals auth)) cred)
|
||||
ctx))
|
||||
|
||||
;;;; simple / basic auth service implementation
|
||||
|
||||
(defclass simple-authenticator ()
|
||||
((principals)))
|
||||
((principals :reader principals :initform (make-hash-table))))
|
||||
|
||||
(defclass simple-credentials ()
|
||||
((login-name)
|
||||
|
@ -42,8 +44,10 @@
|
|||
;;;; login entry point
|
||||
|
||||
(defun login (cred)
|
||||
(let ((srv (core:find-service :auth)))
|
||||
(util:lgi cred (admin-credentials (core:config srv)))))
|
||||
(let* ((srv (core:find-service :auth))
|
||||
(auth (authenticator srv))
|
||||
(admin (gethash :admin (principals auth))))
|
||||
(util:lgi cred admin)))
|
||||
|
||||
;;;; auxiliary functions
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue