diff --git a/lib/auth/auth.lisp b/lib/auth/auth.lisp index 0c4544f..b6cdff0 100644 --- a/lib/auth/auth.lisp +++ b/lib/auth/auth.lisp @@ -21,8 +21,11 @@ (defun setup (cfg) (let* ((auth (make-instance 'simple-authenticator)) (ctx (core:default-setup cfg 'context :authenticator auth)) - (cred (admin-credentials cfg))) - (setf (gethash :admin (principals auth)) cred) + (cred (admin-credentials cfg)) + (head '(:system :admin)) + (data (list :credentials cred)) + (admin (make-instance 'principal :head head :data data))) + (setf (gethash :admin (principals auth)) admin) ctx)) ;;;; simple / basic auth service implementation @@ -47,7 +50,8 @@ (let* ((srv (core:find-service :auth)) (auth (authenticator srv)) (admin (gethash :admin (principals auth)))) - (util:lgi cred admin))) + (util:lgi cred admin) + admin)) ;;;; auxiliary functions diff --git a/lib/auth/test/test-auth.lisp b/lib/auth/test/test-auth.lisp index 3cca97f..93518bd 100644 --- a/lib/auth/test/test-auth.lisp +++ b/lib/auth/test/test-auth.lisp @@ -9,6 +9,7 @@ (:cs-hx :scopes/frontend/cs-hx) (:logging :scopes/logging) (:server :scopes/web/server) + (:shape :scopes/shape) (:t :scopes/testing)) (:import-from :scopes/testing #:deftest #:==) (:export #:run)) @@ -31,6 +32,8 @@ (t:show-result)))) (deftest test-login () - (let ((cred '(:login "admin" :password "secret"))) - (auth:login cred) + (let ((cred '(:login "admin" :password "secret")) + pr1) + (setf pr1 (auth:login cred)) + (== (shape:head-value pr1 :short-name) :admin) ))